0
votes

I have the exact same scenario as this thread: Reload Form on reload/refresh of subgrid in Dynamics 365 CRM Unified Interface

The suggested solution does not work for me unfortunately. The only time the method "subgridEventListener" gets called is when the form loads. If I add or delete records from the subgrid nothing happens..

Does anyone have a possible solution to this problem?

Unified Interface. 2019 release wave 2 enabled Server version: 9.1.0000.16843 Client version: 1.4.583-2004.2 –

1
Did you debug? So the eventhandler is attached to event but not triggering on subgrid reload event? Can you add your snippet you’re using? - Arun Vinoth - MVP

1 Answers

0
votes
//On load of main form event
function OnloadOfMainForm(executionContext) {
// call onLoad of subgrid function
  SubgridEventHandler(executionContext);
} 

var globalFormContext;
function SubgridEventHandler(executionContext){
//make formContext as global
  globalFormContext = executionContext.getFormContext(); 
  var gridContext = globalFormContext.getControl("subgrid_name");

  //Verify the subgrid is loaded, if not recursively call function again
  if (gridContext != null && gridContext != undefined){
      //don't try to pass formEontext some time it doesn't works
      gridContext.addOnLoad(SubgridFunctionExe);
     }else{
        setTimeout(function () { SubgridEventHandler(); }, 200);
     }
}

//Perform operation onLoad of form and subgrid, on refresh of subgrid it will trigger
//as well on add new record and on delete of record it will trigger
function SubgridFunctionExe(){
// here use globalFormContext
  globalFormContext.data.refresh(false);
}

Reference: https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/grids/gridcontrol/addonload