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

One Comment

Leave a Reply

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

*

code

Related Posts

Generate PDF Report in Dynamics CRM 365

Generate PDF Report in Dynamics CRM 365

There is plenty of material available to achieve this very commonly needed functionality to generate PDF of…
Connect to D365 CE Programmatically without MFA/ On-Premise D365 CE

Connect to D365 CE Programmatically without MFA/ On-Premise D365 CE

As a developer, I regularly create connection to my D365 instance (On-Premise) and/or D365 CDS online(MFA and…
Connect to Multi-factor Enabled D365 CDS Programmatically (Online 9.1)

Connect to Multi-factor Enabled D365 CDS Programmatically (Online 9.1)

As per Microsoft announcement, use of the WS-Trust authentication security protocol when connecting to Common Data Service…