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

Get absolutely inspired with Appsolutely Inspired!
May 27, 2020

Get absolutely inspired with Appsolutely Inspired!

We are launching an inspirational series of Salesforce webinars Since corona still has a tight hold ...

Aligning your Global HR Practices with Einstein Analytics
May 19, 2020

Aligning your Global HR Practices with Einstein Analytics

The Top Employers Institute Global Certification Programme is the gold standard for certified global ...

Enriching the world of work for 10 million people - Release 4
April 29, 2020

Enriching the world of work for 10 million people - Release 4

About Top Employers Institute Certification Programme The Top Employers Institute Global Certificati...