简体   繁体   English

Xrm.Utility.openEntityForm设置查找字段

[英]Xrm.Utility.openEntityForm setting Look Up field

I am attempting to use the Xrm.Utility.openEntityForm() method to open a new custom entity form and programatically set an entity look up field. 我试图使用Xrm.Utility.openEntityForm()方法打开一个新的自定义实体表单并以编程方式设置实体查找字段。 I am following an example on http://msdn.microsoft.com/en-us/library/gg334375.aspx very closely but getting nondescript error. 我正在非常密切地关注http://msdn.microsoft.com/en-us/library/gg334375.aspx上的一个示例,但是收到了不明白的错误。 Any help with actually setting the field or possibly finding the logs for the error would be appreciated. 任何帮助实际设置字段或可能找到错误的日志将不胜感激。

The code example I am following. 我正在遵循的代码示例。

 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);
}

The function I have created to do the same with my custom entity is as follows : 我创建的用于对我的自定义实体执行相同操作的函数如下:

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);

}

the name of the entity I am opening a form work = cw_service (this isn't the problem as I can open a blank form with Xrm.Utility.openEntityForm("cw_service");) 我打开表单work = cw_service的实体的名称(这不是问题,因为我可以用Xrm.Utility.openEntityForm(“cw_service”)打开一个空白表单;)

the name of the field I am trying to set is cw_location. 我想要设置的字段的名称是cw_location。

I'd post a picture of the error message but I don't have the reputation yet to do that. 我发布了错误消息的图片,但我还没有声誉。

For simple lookups you must set the value and the text to display in the lookup. 对于简单查找,您必须设置要在查找中显示的值和文本。 Use the suffix “name” with the name of the attribute to set the value for the text. 使用带有属性名称的后缀“name”来设置文本的值。

Don't use any other arguments for simple lookups . 不要使用任何其他参数进行简单查找

For customer and owner lookups you must set the value and the name in the same way you set them for simple lookups. 对于客户和所有者查找,您必须以与为简单查找设置它们相同的方式设置值和名称。 In addition you must use the suffix “type” to specify the type of entity. 此外,您必须使用后缀“type”来指定实体的类型。 Allowable values are account, contact, systemuser, and team. 允许的值包括account,contact,systemuser和team。

For your example, it is a simple lookup, I suppose. 对于您的示例,我想这是一个简单的查找。 So, Please try using the code below: 所以,请尝试使用以下代码:

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

For more information, Please visit Set the value for lookup fields . 有关更多信息,请访问设置查找字段的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xrm.Utility.openEntityForm(entityType,null,参数) - Xrm.Utility.openEntityForm(entityType, null, parameters) 使用Xrm.Utility.openEntityForm()覆盖不同记录中的字段 - Using Xrm.Utility.openEntityForm() to override fields in different record CRM Dynamics,如何使用一种形式传递值,并使用Xrm.Utility.openEntityForm()在新的Entity(form)中设置值; - CRM Dynamics , How to pass values from one form and set the values in a new Entity(form) using Xrm.Utility.openEntityForm(); html查找字段 - html look up field Xrm.Utility.openwebresource打开新选项卡 - Xrm.Utility.openwebresource opens new tab Rails文本字段作为带有查找的选择字段 - Rails text field as select field with look up 设置实用程序类并在 vue 组件中使用它 - Setting up a utility class and using it within a vue component 设置查询以查看对象数组的特定索引 - Setting up a query to look at a specific index of an array of objects Javascript-Dynamics CRM Online-通过openEntityForm将查找字段值传递给表单 - Javascript - Dynamics CRM Online - Passing a lookup field value to a form through openEntityForm 使用范围变量在角度视图中查找对象字段 - Use a scope variable to look up object field in angular view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM