+ Start a Discussion
SFDC_SaurabhSFDC_Saurabh 

force:recordData not loading record

Hello,

I have below lightning markup which should display value of a record from LDS.
<aura:component  implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <aura:attribute name="boatId" type="ID" access="public"/>
    
    <aura:attribute name="record" type="Boat__c" description="The record object to be displayed" access="public"/>
<aura:attribute name="simpleRecord" type="Object" description="A simplified view record object to be displayed" access="public"/>
    <aura:attribute name="recordError" type="String" description="An error message bound to force:recordData" access="public"/>

	Boat details are here for {!v.boatId}
       <force:recordData aura:id="service"
                  recordId="{!v.boatId}"
                   fields="Id,Name"
                   mode="VIEW"
                   targetFields="{!v.record}"
                  
                   targetError="{!v.recordError}"
                    />
    <br/>{!v.record.Name} should come
   
    

</aura:component>
In above code the below line properly displays the id of object.
Boat details are here for {!v.boatId}

But the <force:recordData> does not display the below line.
{!v.record.Name} should come

However in same code if I hardcode the Id of object record as below, it works.
recordId="a061H00000aQlGsQAK"


 
Best Answer chosen by SFDC_Saurabh
SFDC_SaurabhSFDC_Saurabh
I think in my case Force:record data was already rendered before id was retrieved.
 

All Answers

SFDC_SaurabhSFDC_Saurabh
I think in my case Force:record data was already rendered before id was retrieved.
 
This was selected as the best answer
Michael SchröderMichael Schröder
I have a very similar problem. I am trying to read a checkbox field value from a record, but I am not doing it on a record page where recordId would be available. Instead, I pass in a job Id.
 
<force:recordData aura:id="recordLoader" recordId="{!job.Id}"
            fields="action_required__c" targetFields="{!v.accountRecord}"
            targetError="{!v.recordLoadError}" />

This always returns TRUE for v.accountRecord.action_required__c. Even if the checkbox field is not set!

If I substitute {!job.Id} with the actual recordId string, it returns the correct boolean.

What is going on?
Michael SchröderMichael Schröder

I was using the force:recordData within a aura:iteration component, which doesnt seem to work, and also has some serious performance issues apparently: https://salesforce.stackexchange.com/questions/224837/is-it-prudent-to-use-forcerecorddata-and-similar-within-auraiteration

I'll probably try an Apex class to read out the needed fields.