• Power Apps打开记录窗体时候传递额外参数并获取其值


    我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面的微软最有价值专家(Microsoft MVP),欢迎关注我的微信公众号 MSFTDynamics365erLuoYong ,回复413或者20200525可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!

    根据官方文档 Important changes (deprecations) coming in Power Apps, Power Automate, and model-driven apps in Dynamics 365 的说明,Xrm.Page.context.getQueryStringParameters 已经不再推荐使用了,取而代之请用 formContext.data.attributes , 关于这个取而代之的方法有个简单说明如下,能获取很多传递过来的数据,包括 Xrm.Navigation.openForm 传递过来的数据。

    The formContext.data.attributes API will make retrieval of non-entity bound data consistent across entity forms, metadata-driven dialogs, and task-based flows. The data will be a combination of custom values sent using the query string and what was specified in the parameters in the openForm method.

    当然,如果你要在打开窗体的时候传递额外参数过来,首先要对窗体做配置,参考官方文档:Configure a form to accept custom querystring parameters ,简单来说就是打开窗体,点击【Form Properties】。

    在【Parameters】这个tab中设定好参数,当然参数名称要唯一,不要和字段同名,还有最少包括下划线 _ 字符,而且该字符不能为首字符。

    保存发布后,可以参考下面代码在打开现有记录时候传递额外参数过来:

            var caseId = formContext.getAttribute("ly_caseid").getValue();
            if (caseId !== null) {
                var entityFormOptions = {};
                entityFormOptions["entityName"] = "incident";
                entityFormOptions["entityId"] = caseId[0].id;
                var formParameters = {};
                formParameters["l_navigateToTabName"] = "tabApproval";
                Xrm.Navigation.openForm(entityFormOptions, formParameters);
            }

    然后在窗体的onload代码中可以通过类似代码可以获取到值:

            if (formContext.data.attributes && formContext.data.attributes.get("ly_navigateToTabName")) {
                var tabName = formContext.data.attributes.get("ly_navigateToTabName").getValue();
                if (tabName) {
                    formContext.ui.tabs.get(tabName).setFocus();
                }
            }
  • 相关阅读:
    85. Maximal Rectangle
    120. Triangle
    72. Edit Distance
    39. Combination Sum
    44. Wildcard Matching
    138. Copy List with Random Pointer
    91. Decode Ways
    142. Linked List Cycle II
    异或的性质及应用
    64. Minimum Path Sum
  • 原文地址:https://www.cnblogs.com/luoyong0201/p/Dynamics_365_Open_Entity_Form_Pass_Parameter_Get_Parameter_Value.html
Copyright © 2020-2023  润新知