In brief
Two supported refresh patterns cover the most common Dynamics 365 scenarios.
- Use the selected grid control when a command changes home-page view data.
- Use formContext.data.refresh() when you need an asynchronous form refresh.
- Decide explicitly whether the current form data should be saved before refresh.
In Microsoft Dynamics 365, there are many occasions when you need to refresh either a form or a view programmatically using JavaScript. The two approaches below show how to do that through supported APIs.
Refresh the home page grid
Refreshing a view programmatically is useful when a custom button changes data in the home page grid and you want the view to reflect those changes immediately.
In Ribbon Workbench, pass the CRM parameter SelectedControl to your command’s custom JavaScript action. Once processing is complete, call refresh on that control.
selectedControl.refresh();Refresh a form asynchronously
When you are already on a form and have access to its form context, the data API can refresh the form without reloading the entire page.
formContext.data.refresh(save).then(
successCallback,
errorCallback
);Understand the parameters
The refresh method accepts a save choice and optional callbacks for success and error handling.
| Name | Type | Required | Description |
|---|---|---|---|
| save | Boolean | No | Save form data before refreshing when set to true. |
| successCallback | Function | No | Runs when the refresh completes successfully. |
| errorCallback | Function | No | Runs if the refresh operation fails. |
That is all you need for the two most common supported refresh scenarios. Keep the save choice explicit and use callbacks when the surrounding experience needs clear success or error handling.
Related resource




