0

I'm probably missing something crazy simple, hopefully someone here can clear this up for me. I have a simple component as follows:

    <aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome" access="global">
        <aura:attribute name="PricebookEntryRecord" type="String"/>
        <aura:attribute name="PricebookEntry" type="Object"/>
        <force:recordData aura:id="PricebookRecordLoader"
                              fields="Name,IsActive,Extended_Item_Description__c"
                              recordId="{!v.PricebookEntryRecord}"
                              targetFields="{!v.PricebookEntry}"
                              targetError="{!v.recordError}"
                              recordUpdated="{!c.handleRecordUpdated}"
                              />
        {!v.PricebookEntry.Extended_Item_Description__c}
    </aura:component>

The component is passed a record ID from a separate component which is loaded into {!v.PricebookEntryRecord}. When I view the component using some sample data on a lightning page, nothing happens. I don't even see any feedback from handleRecordUpdated in my dev console.

However, if I hardcode the record ID of the sample I'm using into the force:recordData recordId field and refresh the same lightning page from before, everything works just fine and I see the expected logging in my console. I've already confirmed that there is a recordId loaded into {!v.PricebookEntryRecord} as it displays when called, so I'm totally lost as to what the issue is.

1 Answer 1

0

Got it! Special thanks /u/Reddit_Account__c for helping get to the bottom of this. I was dealing with a race condition in the component that was invoking this component. The record ID being referenced in the above code is pulled from a Lookup field on a record and needed to be loaded in before calling the above cmp. To get things working, I needed to invoke this cmp via a change handler as opposed to on initialization of the original cmp.

Relevant documentation for any other greenhorns like myself:

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_data_change.htm -Detecting value changes with change handlers

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_dynamic_cmp_async.htm -Dynamically creating components with the js controller

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .