【问题标题】:Xrm.Utility.openEntityForm setting Look Up fieldXrm.Utility.openEntityForm 设置查找字段
【发布时间】:2014-12-30 00:16:56
【问题描述】:

我正在尝试使用 Xrm.Utility.openEntityForm() 方法打开一个新的自定义实体表单并以编程方式设置一个实体查找字段。我非常密切地关注http://msdn.microsoft.com/en-us/library/gg334375.aspx 上的一个示例,但出现了无法描述的错误。任何有关实际设置字段或可能查找错误日志的帮助将不胜感激。

我正在关注的代码示例。

 function OpenNewContact() {

 var parameters = {};

 //Set the Parent Customer field value to “Contoso”.
 parameters["parentcustomerid"] = "2878282E-94D6-E111-9B1D-00155D9D700B";
 parameters["parentcustomeridname"] = "Contoso";
 parameters["parentcustomeridtype"] = "account";

 //Set the Address Type to “Primary”.
 parameters["address1_addresstypecode"] = "3";

 //Set text in the Description field.
 parameters["description"] = "Default values for this record were set programmatically.";
 //Set Do not allow E-mails to "Do Not Allow".
 parameters["donotemail"] = "1";

 // Open the window.
 Xrm.Utility.openEntityForm("contact", null, parameters);
}

我创建的用于对自定义实体执行相同操作的函数如下:

function createNewService() {
    var locationId = trimBrackets(Xrm.Page.data.entity.getId());

    var primaryField = Xrm.Page.data.entity.getPrimaryAttributeValue();

    var entityLogicalName = Xrm.Page.data.entity.getEntityName();

    var parameters = {
        cw_location: locationId,
        cw_locationname: primaryField,
        cw_locationtype: entityLogicalName
    };

    Xrm.Utility.openEntityForm("cw_service", null, parameters);

}

我打开表单的实体名称 work = cw_service(这不是问题,因为我可以使用 Xrm.Utility.openEntityForm("cw_service"); 打开一个空白表单)

我要设置的字段名称是 cw_location。

我会发布错误消息的图片,但我还没有这样做的声誉。

【问题讨论】:

  • 为了测试,尝试将您在表单 JS 上设置 cw_service.cw_location 字段时使用的值硬编码到您的参数中。也就是说,通过 JS 在 cw_service 表单上设置查找字段,然后将工作值复制/粘贴到您的 createNewService 函数中,看看会发生什么。

标签: javascript dynamics-crm-2013 xrm


【解决方案1】:

对于简单的查找,您必须设置要在查找中显示的值和文本。使用带有属性名称的后缀“name”来设置文本的值。

不要使用任何其他参数进行简单查找

对于客户和所有者查找,您必须以与为简单查找设置相同的方式设置值和名称。此外,您必须使用后缀“type”来指定实体的类型。允许的值为帐户、联系人、系统用户和团队。

对于您的示例,我想这是一个简单的查找。所以,请尝试使用下面的代码:

var parameters = {
    cw_location: locationId,
    cw_locationname: primaryField
};

欲了解更多信息,请访问Set the value for lookup fields

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-23
    • 1970-01-01
    • 2021-12-14
    相关资源
    最近更新 更多