Refreshing a Lightning Aura component when a record is updated via the standard Salesforce UI
twitter social iconlinkedin social iconfacebook social icon

Refreshing a Lightning Aura component when a record is updated via the standard Salesforce UI

Lightning components offer a number of solutions to allow integration with Salesforce’s standard functionality, but one of the challenges people sometimes face is when a component needs to update, refresh or otherwise change as the result of a change to a standard object via the Salesforce UI. In the circumstances where no other triggering mechanisms are available, the option to ‘watch’ the Salesforce UI for changes would be useful. 

Lightning Data Service

In order to resolve this issue, we have one interesting approach using Lightning Data Service. Lightning Data Service (LDS) is a mechanism within the Lightning Experience that allows a custom Lightning component to retrieve data from Salesforce objects. 

The implementation of this is relatively simple, we add the code below to the markup and specify an attribute that the record data should be mapped to.

In addition to this, we can trigger actions on a change of this data, using the ‘recordUpdated’ attribute.

Shared Caching

Lightning Data Service and the standard Salesforce UI share an integrated cache, so that if one is updated the others also reflect that change. This means that if our custom component makes a change to the record in question, the standard UI does not continue to display stale date.

Similarly, we can leverage this functionality in the opposite direction to trigger a change within our component:



JS Controller

recordUpdated : function(component, event, helper) {
 // Your custom functionality here
 alert(‘I have changed’);}

In this simple example we can allow a change to any fields within the given record to trigger custom functionality in our component, assuming the component is active at the time of the change.

We can also determine the type of change and handle each with different behaviours. For more information on change types, see or contact us!

Share this article:
twitter social iconfacebook social iconlinkedin social icon