javascriptdynamics-crmmicrosoft-dynamicsdynamics-crm-uci

Reload Form on reload/refresh of subgrid in Dynamics 365 CRM Unified Interface


I have a scenario where in Orders Form there is a Invoice Schedule Sub-grid. I need to Refresh/Reload the Main Form when the Invoice Schedule Sub-grid is reloaded on Deactivating a particular record in the Sub-grid.

P.S: This scenario is for Dynamics 365 CRM Unified Interface (UCI). I have tried all the three Sub-grid events but does not help in this scenario.


Solution

  • You have to attach a custom event handler to deal this. Read more

    var globalFormContext;
    
    function myFormOnload(executionContext) {
      globalFormContext = executionContext.getFormContext(); 
    
      addSubgridEventListener();
    } 
    
    function addSubgridEventListener(){
      var gridContext = globalFormContext.getControl("<your_subgrid_name>");
      //ensure that the subgrid is ready…if not wait and call this function again
      if (gridContext == null){
         setTimeout(function () { addSubgridEventListener(); }, 500);
         return;
      }
      //bind the event listener when the subgrid is ready
      gridContext.addOnLoad(subgridEventListener);
    
    }
    
    function subgridEventListener(context){
      globalFormContext.data.refresh(false);
    }