You need to sign in to do that
Don't have an account?
Admin DEV 13
$A.get('e.force:refreshView').fire() did not refresh the record detail component
Hi,
I create a lightning component for the lightning experience record pages. In the customize record page, I drag standard Record Detail component and my componont to the page. In my component, I update some fields of a record. After I save those field, I fire up the e.force:refreshView event. But the standard record detail component did not refresh to show the new value of those field. Is there any way to force to refresh the standard record detail component?
I create a lightning component for the lightning experience record pages. In the customize record page, I drag standard Record Detail component and my componont to the page. In my component, I update some fields of a record. After I save those field, I fire up the e.force:refreshView event. But the standard record detail component did not refresh to show the new value of those field. Is there any way to force to refresh the standard record detail component?
You are not supposed to give same name to the apex controller's method and the function which is called on click. Also, you should pass event along with the component in the same.
Please find the code below:-
Controller:-
Note save and apexSave.
The server-side action is also provided by the “c” value provider. This is the same value provider that provides the JavaScript controller event handler which handles the press event of the button and the init event. Because of this, you need to make sure that you do not name your Apex controller methods with the same name as your JavaScript controller methods. It’s easy to make the mistake of naming them same because it is natural to want to be consistent in naming.
Source:- Salesforce1 Lightning Components – Working with Controllers
You may use an aura handler to make sure that whether it has been refreshed successfully.
Hope this helps.
Best Regards,
Nagendra.P
You need to fire the event upon checking up whether the server returns the success response or not. use the below code snippet.
action.setCallback(this, function(response) {
if(response.getState() === SUCCESS){
$A.get('e.force:refreshView').fire();
}
});
Let me know if you have any questions. Mark the answer as best if you could resolve this.
Regards,
Priyanka S
I'm using force:editRecord in my component and once the record is save I call $A.get('e.force:refreshView').fire();
All the events are being fired, however, the component doesn't really reload. How am I sure of that? Because I have a trigger that changes the RecordType and that RecordType is assigned to a different layout. After the record is saved and I refresh the page by myself the layout is changed.
Any ideia?
Thanks
Please do like the below:-
Please don't forget to give the below in your component:-
Change it according to your needs.
Hope this worked.
Please mark it as the best answer.
Thanks and regards,
Aboo
To reload a view, run Location.reload();, which reloads all data for the view.
This example refreshes the view after an action is successfully completed.
action.setCallback(this, function(response) {
if(response.getState() === SUCCESS){
Location.reload();
}
});
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
to reload my entire page. Works like a charm. Love the native javascript :)