首页 > 解决方案 > 在 Dynamics 365 CRM 统一接口中重新加载/刷新子网格时重新加载表单的问题

问题描述

我有与这个线程完全相同的场景: Reload Form on reload/refresh of subgrid in Dynamics 365 CRM Unified Interface

不幸的是,建议的解决方案对我不起作用。唯一一次调用“subgridEventListener”方法是在表单加载时。如果我从子网格中添加或删除记录,则不会发生任何事情..

有没有人可以解决这个问题?

统一接口。2019 年发布第 2 波启用服务器版本:9.1.0000.16843 客户端版本:1.4.583-2004.2 –</p>

标签: refreshreloaddynamics-365subgrid

解决方案


//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);
}

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


推荐阅读