【问题标题】:Reload Form on reload/refresh of subgrid in Dynamics 365 CRM Unified Interface在 Dynamics 365 CRM 统一界面中重新加载/刷新子网格时重新加载表单
【发布时间】:2020-01-27 11:02:44
【问题描述】:

我有一个场景,订单表格中有一个发票计划子网格。我需要在 Deactivating 上重新加载 Invoice Schedule Sub-grid 时刷新/重新加载 Main Form记录在子网格中。

P.S:此方案适用于 Dynamics 365 CRM 统一接口 (UCI)。我已经尝试了所有三个子网格事件,但在这种情况下没有帮助。

【问题讨论】:

    标签: javascript dynamics-crm microsoft-dynamics dynamics-crm-uci


    【解决方案1】:

    您必须附加一个自定义事件处理程序来处理这个问题。 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);
    }
    

    【讨论】:

    • 嗨@arunvinoth,感谢您的回答,它有效,但我遇到了一个错误,它使子网格进入无限循环。由于我的基本要求是刷新主窗体功能区,因此我使用了 globalFormContext.ui.refreshRibbon(false); 而不是 globalFormContext.data.refresh(false);,这对我来说很好。
    • 这行得通吗?我用这段代码进行了测试,但唯一一次调用“subgridEventListener”方法是在表单加载时。如果我从子网格中添加或删除记录,则不会发生任何事情。统一接口。 2019 年发布第 2 波启用服务器版本:9.1.0000.16843 客户端版本:1.4.583-2004.2
    • @TobyFieldgroove 开始一个新问题,如果它添加了更多上下文,请标记此线程
    • 我对此解决方案有疑问,请参阅此主题:stackoverflow.com/questions/61814065/…
    【解决方案2】:

    此最新代码经过验证,可在 v9 统一界面中运行 参考:https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/grids/gridcontrol/addonload

    代码sn-p:

    //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);
         }
    }
    
    //It triggers onLoad of form, on load and on refresh of subgrid
    //as well on add new record and on delete of record it will trigger
    function SubgridFunctionExe(){
    // here use globalFormContext
      globalFormContext.data.refresh(false);
    }
    

    【讨论】:

      【解决方案3】:

      对于 UCI: 从功能区按钮传递 PrimaryControl 的参数并使用以下代码刷新。

      PrimaryControl.refresh();
      

      【讨论】:

        猜你喜欢
        • 2020-08-31
        • 1970-01-01
        • 2013-08-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多