[SalesForce] Reload record detail lightning page on edit

Is there a way to reload the Lightning page after saving the record detail? I have embedded a custom Lightning component on the Lightning page and trying to reload the page to use the updated field values on the record.

Best Answer

Use below code, if success is returned below code line should be fired. $A.get("e.force:refreshView").fire();

A sample method can be written as

refresh : function(component, event, helper) {
var action = component.get('c.myController');
action.setCallback(component,
    function(response) {
        var state = response.getState();
        if (state === 'SUCCESS'){
            $A.get('e.force:refreshView').fire();
        } else {
             //do something
        }
    }
);
$A.enqueueAction(action);

} https://developer.salesforce.com/docs/component-library/bundle/force:refreshView/documentation

Are you in the context of a custom lightning app? The default refreshView event is only available within the Lightning Experience / mobile Salesforce-App context. Say if you want to use the event within a .app you have to register and handle the event manually and cannot use the out-of-the-box behaviour.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_one.htm