0

i used LDS to get child recordid from parent record and lightning:form to show/edit for child object record, after successfully update the child record still shows old date in lightning:recordform even though after successfully fire the $A.get('e.force:refreshView').fire()

cmp

<aura:attribute name="RecEventrecord" type="Object"/>
    <aura:attribute name="fields" type="String[]" default=" 
   ['field1__c','field2__c','field3__c']"/>
<aura:handler name="change" value="{!v.parentrecord.child__c}" action="{!c.doInit}"/> // not working even though i fired init handler in refresh event
<aura:handler event="force:refreshView" action="{!c.doInit}" /> // not working with this also
 <force:recordData aura:id="precord"
                  recordId="{!v.recordId}"
                  layoutType="FULL"
                  targetFields="{!v.parentrecord}"
                  targetError="{!v.recordError}"
                 recordUpdated ="{!c.loadeventhandler}"/>


  <aura:if isTrue="{!not(empty(v.parentrecord.child__c))}">
      <lightning:card class="slds-card_boundary">
          <lightning:recordForm density="comfy"
                 recordId="{!v.parentrecord.child__c}"
                 objectApiName="child__c"
                 fields="{!v.fields}"
                 columns="4"
                 mode="view"
                onsubmit="{!c.handleEdit}"
                onsuccess ="{!c.handleEditsuccess}"
                onerror = "{!c.handleError}"/>
     </lightning:card>

cmpcontroller.js

handleEditsuccess : function(component,event,helper){
          $A.get('e.force:refreshView').fire();
    },
0

In your recordUpdated handler (loadeventhandler) you need to reload the record manually

if(eventParams.changeType === "CHANGED"){
    component.find("precord").reloadRecord();
}

Here is the related documentation : https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service_handling_record_change.htm

  • i am not updating parent record, i think u understood different way, i am updating child record vialightning:recordform i am using LDS for parent record details. u r answer is not useful – sdandamud1 Sep 19 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.