Search This Blog

Sunday, January 15, 2023

DYNAMICS 365 HOW TO REFRESH SUBGRID IN JAVASCRIPT

 we will see how to refresh a subgrid in JavaScript in order to show the latest records related to a parent record upon an action on the form or clicking a ribbon button.


For the sake of this post, I will take the example of the cases subgrid related to an account record.

Refresh subgrid in JavaScript

Let's take the scenario, where an action is done on the client side that adds a case related to the account record. Therefore, the sub-grid should be automatically refreshed to reflect the updated list of cases.

In order to do this, a JavaScript function should call the refresh() in order to refresh the subgrid and display the expected result.

function refreshSubGrid(context) {
var formContext = context.getFormContext();
var subgrid = formContext.ui.controls.get("cases"); //Put the appropriate sub-grid name
subgrid.refresh();
}


Refresh subgrid in JavaScript 2

In case you are opening a web resource where you need to refresh the sub-grid, you can use the parent.Xrm.Page.ui.controls.get("cases").refresh(); or the form context as detailed in this post.

References:


No comments:

Post a Comment