Refresh CRM Grid using JavaScript

In Microsoft Dynamics 365, there are many occasions that you need to refresh either form or view programmatically using JavaScript. I will list down how you can achieve this in supported way.  

Home Page Grid refresh 
It is little tricky to refresh view programmatically. One of the common scenario where you need to do this is if you have a custom button on home page grid and would like to refresh view to automatically reflect the changes. There is a supported way to achieve this.  

Using Ribbon Workbench pass CRM Parameter ‘SelectedControl’ to your command’s Custom JS action, and then in JS function just use below line after all the processing is completed.  

Syntax
selectedControl.refresh(); 

Form Refresh
As you are on form and you have access to form context, it is very easy to refresh form asynchronously without reloading the page as shown below

Syntax
formContext.data.refresh(save).then(successCallback, errorCallback); 

Parameter

Name  Type  Required  Description 
save  Boolean  No  true if the data should be saved after it is refreshed, otherwise false. 
successCallback  Function  No  A function to call when the operation succeeds. 
errorCallback  Function  No  A function to call when the operation fails. 

Hope this helps to achieve your goal in supported way. Please share your comments.  

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on LinkedIn
Share on pinterest
Share on Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts