Force:refreshView is an event that can be used to refresh the view. To elaborate, consider a scenario where you have a custom component on the Account detail page and this component consists of a form that updates a field on the account. Now, after you save the record the field will be updated and will be reflected on the component itself but not on the account detail page.To achieve that we have force:refreshView. There may be 2 cases in this scenario:-
Case 1: Updating standard view from custom component
Let’s say, we have a component which creates a related contact of an account. Now after filling in all details and clicking on save the contact will be created but the related list component of account will not update. Here we can achieve this by firing the force:refreshView event after the save. Consider the following component:
Case 2: Updating Custom component view from Standard component
This case is the opposite of the above case. For example, let’s say we have a component that displays some fields of the account like Name, Type etc. Now, when we update those fields on the standard component those changes will not be reflected on our custom component unless we handle the force:refreshView event by creating handler to refresh the component. In this scenario we initialize the component in the handler of force:refreshView.
Consider the following code:
If you're ready to find out more about how SimplusLabs can help energize your workers, your customers, and your business with a different experience, let's talk.