I have a Quick Action button on the Highlight Panel of Case page that launches a Lightning Aura Comp (QA: Detail page button with URL). Through pageReference, I was able to access the parent CaseId. Now that I have CaseId, how can I fetch few field values of this Case record without Apex controller class?
I've tried:
CMP
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="CaseId" type="String" />
<aura:attribute name="caseRecord" type="Object"/>
<aura:attribute name="recordError" type="String"/>
<force:recordData aura:id="recordLoader"
fields="Sample__c"
recordId="{!v.CaseId}"
targetFields="{!v.caseRecord}"
targetError="{!v.recordError}"
recordUpdated="{!c.handleRecordUpdated}"
/>
JS
handleRecordUpdated: function(component, event, helper){
console.log('Inside Handle method'); //Not getting logged.
var eventParams = event.getParams();
if(eventParams.changeType === "LOADED") {
console.log("Case loaded with:" + component.get("v.caseRecord"));
}
}
I couldn't get any log for the above debug statement. So, not sure if the function handleRecordUpdated
even gets fired.
I do have implementation for creating a subtab within doInit
.
Update: To give more context, I have a Case landing page where we have a Highlight panel. Here, we are implementing a QuickAction button of display type: Detail Page Button with URL as: /lightning/cmp/c__MySampleAuraComponent. This Aura comp contains doInit where we are using workspaceAPI
to open a subtab for a custom object's standard record creation form. So, to prepopulate few fields from Case object, I was trying to fetch parent case field values. I know I could go down the Apex controller path, but decided to give it a try without it to minimize code maintenance.
I have tried Lightning Message Services to publish the necessary fields, but no luck with QuickAction implementation on the highlights panel.
Update 11/22: I am setting the CaseId value within my doInit
function and I can verify the data in my console. But not sure why it is not getting passed to force:recordData
as I don't see any log from handleRecordUpdated
.