Refresh SubGrid Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/tag/refresh-subgrid/ Microsoft Dynamics CRM . Microsoft Power Platform Wed, 08 Jul 2020 16:05:34 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/cropped-Microsoftdynamics365-blogs.png?fit=32%2C32 Refresh SubGrid Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/tag/refresh-subgrid/ 32 32 176351444 Refresh SubGrid – Not Working – Issue while refreshing Sub grid using JavaScript -Refresh SubGrid from HTML webresource http://microsoftdynamics.in/2020/07/08/refresh-subgrid-not-working-issue-while-refreshing-sub-grid-using-javascript-refresh-subgrid-from-html-webresource/ Wed, 08 Jul 2020 16:05:34 +0000 http://microsoftdynamics.in/?p=3866 The post Refresh SubGrid – Not Working – Issue while refreshing Sub grid using JavaScript -Refresh SubGrid from HTML webresource appeared first on Microsoft Dynamics 365 Blog.

]]>

With Recent Requirement, we developed a Custom Multiple File uploader on an entity which uploads multiple files in Notes or Attachment (Unsupported for sure),


Once the upload is done we needed Notes Grid or Attachment subgrid to refresh, but as we were running js from HTML Resource, so we followed below code

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/07/img_5f05ec766f06a.png?fit=1497%2C746

There are 2 ways we can use it.

1. Using it from Html Resource where we want to use DOM. ( Unsupported not recommended)

parent.document.getElementById("attachmentsGrid").control.refresh();

2. Using Js from an Iframe, use Parent

parent.Xrm.Page.getControl("attachmentsGrid").refresh();

// Form Context (Recommended)

formContext.getControl(“attachmentsGrid”).refresh();

3. Using Js on the Record Itself

Xrm.Page.getControl("attachmentsGrid").refresh();

// Form Context (Recommended)

formContext.getControl("attachmentsGrid").refresh();

We Might be sometime not Seeing above code working, I would recommend debugging it, but the most common issue might be that Code is rendering Before Form is fully loaded.

We can use the below code, to the first check if the context is not null and if null is found return and try after 1 sec that is 1000ms.

Function test(executionContext)
{
//// Get FormContext
formContext = executionContext.getFormContext();
if(formContext  != null)
{
//// Get Grid Control
Var getSubgrid = formContext.getControl("attachmentsGrid");
////If Grid Control is empty , Return and timeout for 1 sec
if(getSubgrid  == null)
{
 setTimeout(function () { test(executionContext); }, 1000);
     return;
}
//// If control is not null refresh the grid
formContext.getControl("attachmentsGrid").refresh();
}

}

The post Refresh SubGrid – Not Working – Issue while refreshing Sub grid using JavaScript -Refresh SubGrid from HTML webresource appeared first on Microsoft Dynamics 365 Blog.

]]>
3866