function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Clemens MittlClemens Mittl 

Lightning Data Service recordUpdated function does not get executed

Hello  everyone,
i am recently working on some features using the Lightning Data Service and i am facing a somewhat strange condition.
 
Component A is working fine as intended:
Via the LDS recordData component it fetches data, runs logic on it in the recordUpdated function and renders some markup for presentation of the data.
The User is provided with the oppportunity to interact with the data and upon a button click some changed data is send back to the server via the recordData save function.
 
 
Component B holds some more markup and is utilizing another child component, an ApexController and Custom Event (for communication between child Component C and parent Component B) for it´s main logic and presentation.
 
The LightningDataService part via recordData however is implemented exactly the same as in Component A to fetch some data in the recordUpdated function and save data back once processing in the custom component is done.
 
For some reason it seems that in Component B the recordUpdated function in the controller is never executed and i therefore cannot work with the fetched data. I checked multiple times and the LDS part is setup in the exact same manner as in Component A - which is working.
 
 
Both Component A & B are placed on the Account Record.
 
 
recordData snippet from Component B
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="record" type="Object"/>
    <aura:attribute name="simpleRecord" type="Object"/>
    <aura:attribute name="recordError" type="String"/>
 
   <force:recordData aura:id="recordHandler" recordId="{!v.recordId}"
          targetRecord ="{!v.record}"
          targetFields ="{!v.simpleRecord}"
          fields="backendtextfield__c"
          recordUpdated="{!c.recordUpdated}"
          mode="EDIT"/>
 
 
recordUpdated snippet from Controller B
 
recordUpdated: function(component, event, helper) {
        console.log("record Updated function is reached");
              var eventParams = event.getParams();
        if(eventParams.changeType === "LOADED" || eventParams.changeType === "CHANGED") {
           // record is loaded or changed (render other component which needs record data value)
            console.log("Record loaded");
                      
          // this is where some logic will be placed


        } else if(eventParams.changeType === "REMOVED") {
            // record is deleted
        } else if(eventParams.changeType === "ERROR") {
            // there’s an error while loading, saving, or deleting the record
           
        }
    }
 
 
Do i miss some incompatibilities of LDS with other Lightning building blocks?
 
 
Thanks for any ideas and directions,
Clemens
Clemens MittlClemens Mittl

To add to the confusion:

I tried to add both Components to another Object (Contact) and there both Components are working fine (their respective recordUpdated functions are called) - but on an Account record only one recordupdated function (of Component A) is called.