RE: Subgrid modification forcing main form refresh
Hi Diane,
Depends on your requirement please proceed to implement.
Refresh Form Subgrid form Add new Popup window , Replace the subgrid Name. You may need to add additional "parent" if you are showing the subgrid inside TAB. You need to register the function (onSavePopUp) in the OnSave method of Add New window of subgrid.
//Refresh Form Subgrid From Add New Popup window
function onSavePopUp() {
Xrm.Page.data.save().then(executeSubmitSuccessfulCallback, executeSubmitErrorCallback);
}
function executeSubmitSuccessfulCallback() {
var subgrid = document.parentWindow.parent.parent.opener.Xrm.Page.ui.controls.get("SUBGRID ID"); // Replae the subgrid Name. You may need to add addtional parent if you are showing the subgrid in a TAB.
subgrid.refresh();
Xrm.Page.data.entity.save('saveandclose');
}
function executeSubmitErrorCallback() {
}
Refresh the data in the Form , Using Xrm.Page.data.refresh method you can manually force the page to display the current values.
If you have any web resource in the form you can simply set the webresource URL to refresh particular form.
var url = Xrm.Page.getControl("WebResource_Name").getSrc
Xrm.Page.getControl("WebResource_Name").setSrc(null);
Xrm.Page.getControl("WebResource_Name").setSrc(url);
Please note when you will calling Xrm.Page method from popup its trigger only the pop window context , not for parent form . So you need to debug and check to get the control from parent form like below.
document.parentWindow.parent.parent.opener.Xrm.Page // You may need to add additional parent here .
Hope this helps.