0

Got pretty basic task of loading Lead info via LDS. Whenever this page loads, LDS doesn't do anything - no error, no warning.

<aura:component implements="lightning:isUrlAddressable">
    <aura:attribute name="lead" type="Lead"/>
    <aura:attribute name="pageReference" type="Object"/>
    <aura:attribute name="recordError" type="String"/>
    <force:recordData aura:id="recordLoader"
                      fields="['Id','CreatedDate','Address']"
                      recordId="{!v.pageReference.state.lead}"
                      targetFields="{!v.lead}"
                      targetError="{!v.recordError}"
                      recordUpdated="{!c.handleRecordUpdated}"/>
    <lightning:card title="Some title" footer="{!v.recordError}">
        <aura:set attribute="actions">
            <lightning:button label="Save Progress"/>
        </aura:set>
        {!v.lead.Address.Street}
    </lightning:card>
</aura:component>

Controller:

handleRecordUpdated: function(component, event, helper) {
    var eventParams = event.getParams();
    if(eventParams.changeType === "LOADED") {
        console.log("Record is loaded successfully.");
    } else if(eventParams.changeType === "CHANGED") {
        console.warn("record is changed");
    } else if(eventParams.changeType === "REMOVED") {
        console.warn("record is deleted");
    } else if(eventParams.changeType === "ERROR") {
        console.error("Record load err");
    }
},

1 Answer 1

4

You are using the compound field Address. Instead use individual Fields mentioned in the Salesforce Field Reference Guide in your fields attribute for the force:recordData

  1. Street
  2. City (etc...)

I haven't tried using your example but this is a working example from my dev org just for you.

<aura:attribute name="record" type="Object"/>
<aura:attribute name="simpleRecord" type="Object"/>
<aura:attribute name="recordError" type="String"/>

<force:recordData aura:id="recordLoader"
  recordId="{!v.recordId}"
  targetFields="{!v.simpleRecord}"
  targetError="{!v.recordError}"
  recordUpdated="{!c.handleRecordUpdated}"
                  fields="Id, Name, City, State"
  />

<!-- Display a lightning card with details about the record -->
<div class="Record Details"> 
<lightning:card iconName="standard:account" title="{!v.simpleRecord.Name}" >
    <div class="slds-p-horizontal--small">
        <p class="slds-text-heading--small">
            <lightning:formattedText title="Billing City" value="{!v.simpleRecord.City}" /></p>
        <p class="slds-text-heading--small">
            <lightning:formattedText title="Billing State" value="{!v.simpleRecord.State}" /></p>
    </div>
</lightning:card>
</div>

<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
    <div class="recordError">
        {!v.recordError}</div>
</aura:if>

enter image description here

1

You must log in to answer this question.

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