0

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.

2
  • Are you updating the field values from Your custom Lightning Component? And you expect the standard detail page to be updated based on update from custom component? – sanket kumar Sep 9 '19 at 15:40
  • @sanketkumar Its the other way around. The custom component has a form that has fields from different objects and few fields with values prepopulated from the record detail. When the value of a field is updated on the record detail, it is not reflecting in the form unless I force reload the page. If it were the component that reloads the page, I can use force:refreshView. But since this is the other way around I am not sure how to refresh the page (or reload all components on the page) on record save. – yeselkay Sep 9 '19 at 16:36
1

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

2
  • Tried this but the force:refreshView event does not reload the whole page, and my component does not get the updated field values from the record detail. – yeselkay Sep 9 '19 at 7:25
  • You getting success as state from apex? Try using Location.reload(); to refresh the full view – Shubham Nandwana Sep 9 '19 at 9:43
0

force:refreshView is used to refresh the view when you need to get new data. Something like this:

$A.get("e.force:refreshView").fire();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.