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

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:

Markup

Appsolutely

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 developer.salesforce.com or contact us!

 

 

 


Deel dit artikel:
twitter social iconfacebook social iconlinkedin social icon

divider graphic

Related news

Update Picklist Values on Package Upgrade
March 31, 2020

Update Picklist Values on Package Upgrade

While upgrading the managed package we often forgot about the picklist field which has a limitation ...

Meet Hugo
March 17, 2020

Meet Hugo

What’s that? The sound of a new colleague entering the stage… Say hi to Hugo! This 28-year-old board...

User Access to Custom Settings in Salesforce
March 11, 2020

User Access to Custom Settings in Salesforce

With recent changes to permissions relating to Salesforce custom settings you may find that your Sal...