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

Meet Guilherme
December 20, 2019

Meet Guilherme

Christmas came early this year, because we’ve got a brand-new member on our team! Meet Guilherme Uhe...

Enriching the world of work for 10 million people - Release 3
December 2, 2019

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

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

Meet Diego
November 26, 2019

Meet Diego

Knock, knock. Who’s there? It’s our newest employee, Diego Maranhão. The 29-year old newlywed has ju...