0

I'm overriding an edit button on a custom object named schedule, which has a lookup relationship with the lead object. But when I try to lead fields through force:recorddata is returning null values.

Component:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,lightning:actionOverride" access="global" >
    <aura:attribute name="activeSections" type="List" default="['A']" />
    <aura:attribute name="currentUser" type="User"/>
    <aura:attribute name="leadRecordLoadError" type="String"/>
    <aura:attribute name="leadDetails" type="object"/>
    <aura:attribute name="leadRec" type="Id"/>
    <lightning:recordEditForm
            aura:id="editIntroForm"
            recordId="{!v.recordId}"                 
            onload="{!c.handleLoad}"
            onsubmit="{!c.handleSubmit}"
            onsuccess="{!c.handleSuccess}"   
            objectApiName="Intro_Call__c">
        <force:recordData aura:id="ldRecordLoader" recordId="{!v.leadRec}"
                          fields="Name" 
                          targetFields="{!v.leadDetails}"
                          targetError="{!v.leadRecordLoadError}"
                          recordUpdated="{!c.recordUpdated}"/>
<lightning:inputField aura:id="meetingStatus" fieldName="Meeting_Status__c" onchange="{!c.displaySection2}"/>

controller:

recordUpdated : function(component, event, helper) {
        var changeType = event.getParams().changeType;
        if (changeType === "LOADED") {
           var acDetails =component.get("v.leadRecordLoadError");
                //console.log('@acDetaisonloadedl@@'+acDetails);    
        } else if (changeType === "ERROR") {
            var acDetails =component.get("v.leadRecordLoadError");
                console.log('@acDetaisonloadedl@@'+acDetails);
        } /* also have REMOVED and CHANGED */
        
    },
displaySection2 : function(component, event, helper)
    {
        var qualified = component.find("meetingStatus").get("v.value");
        var acDetails =component.get("v.leadRecordLoadError");
        console.log('@acDetaisl@@'+acDetails);    
    },

Please help where I have missed

4
  • Are you doing this in the init handler?
    – sfdcfox
    Commented Nov 1, 2021 at 17:44
  • Sorry, my bad. Actually, console logs are not displayed from the leadRecordLoadError method. I'm not sure why these logs are not priniting
    – Pavan tej
    Commented Nov 1, 2021 at 17:52
  • Not sure you're allowed to use both fields AND layoutType. Try removing one or the other. Also, did you check recordLoadError attribute?
    – sfdcfox
    Commented Nov 1, 2021 at 17:53
  • I have removed the layout and recordLoadError attribute showing undefined
    – Pavan tej
    Commented Nov 1, 2021 at 18:01

0

You must log in to answer this question.