【问题标题】:Xrm.Navigation.openForm set lookup field automatically from the previous formXrm.Navigation.openForm 自动从前一个表单设置查找字段
【发布时间】:2021-12-14 10:46:05
【问题描述】:

我在“Parcours”表单中添加了一个新按钮,该按钮将我带到另一个表单“问题”,并带有Xrm.Navigation.openForm

“问题”表单有一个来自“Parcours”的查找字段,我想从以前的表单中自动填充它,例如:

这是我的按钮代码,我想自动检测 parcours 的 ID 并将其设置在新的“问题”表单中

function NavigateQuestion(){
    var entityFormOptions = {};
entityFormOptions["entityName"] = "zs_question";
var formParameters = {};

// Set lookup column
formParameters["zs_parcours"] = ""; // I want to put the ID here from the previous form.
formParameters["zs_parcoursname"] = ""; // Name of the parcours.
formParameters["zs_parcourstype"] = "zs_parcours"; // Table name. 

Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
    function (success) {
        console.log(success);
        console.log(formParameters);
    },
    function (error) {
        console.log(error);
    });


}

【问题讨论】:

    标签: javascript dynamics-crm powerapps xrm


    【解决方案1】:

    您应该能够从当前记录表单本身获取值并进行分配。

    确保为最新的客户端 API 方法传递 formContext(我将语法放在注释代码部分)。

    // Set lookup column
    formParameters["zs_parcours"] = Xrm.Page.data.entity.getId(); // or by using form context -- formContext.data.entity.getId();
    formParameters["zs_parcoursname"] = Xrm.Page.getAttribute("zs_name").getValue(); // or by using form context -- formContext.getAttribute("zs_name").getValue();
    formParameters["zs_parcourstype"] = "zs_parcours"; 
    

    【讨论】:

      猜你喜欢
      • 2019-05-07
      • 2011-07-08
      • 2011-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-29
      • 2021-12-31
      • 1970-01-01
      相关资源
      最近更新 更多