4

我正在尝试使用 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。

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

4

1 回答 1

3

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

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

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

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

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

有关详细信息,请访问设置查找字段的值

于 2015-01-05T06:42:32.623 回答