简体   繁体   English

如何在 Dynamics CRM 中使用 openForm 设置多选字段值?

[英]How to set multi-select field value using openForm in Dynamics CRM?

I've created Multi-select option-set field (category) in Dynamics CRM on-premise for Contact and Projects.我在 Dynamics CRM on-premises 中为联系人和项目创建了多选选项集字段(类别)。 Now using button click I'm trying to set the value of multi-select field on Project.现在使用按钮单击我正在尝试在项目上设置多选字段的值。 But each time I am coming across with Error:但是每次我遇到错误时:

Error converting value 920650008 to type System.Collections.Generic.List 1[System.Int32] . Error converting value 920650008 to type System.Collections.Generic.List 1[System.Int32]

Since the multi-select optionset field is global so there is no chance of specified values available or not.由于多选选项集字段是全局的,因此没有指定值可用或不可用的机会。

Here is what I am trying previously:这是我以前尝试过的:

var name = formContext.getAttribute(new.account_metada.CompanyName).getValue();
var entityFormOptions["entityName"] = "new_projects";
    entityFormOptions["openInNewWindow"] = true;
var formParameters["new_company"] = id; 
    formParameters["new_companyname"] = name;
    formParameters["new_category"]  = formContext.getAttribute("new_category").getValue()

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

Please let me know how to can I set value of multi-select optionset using Xrm.Navigation.openForm请让我知道如何使用Xrm.Navigation.openForm设置多选选项集的值

I tested this personally and getting the same error result with the below snippet.我亲自对此进行了测试,并使用以下代码段得到了相同的错误结果。 Though the syntax is right - Something could be wrong with the Xrm.Navigation.openForm() method or this could be expected behavior because of unsupported Array datatype .虽然语法是正确的- Xrm.Navigation.openForm()方法可能有问题,或者这可能是由于不受支持的 Array 数据类型而导致的预期行为。

var entityFormOptions = new Array();
entityFormOptions["entityName"] = "my_entity";
entityFormOptions["openInNewWindow"] = false;

var formParameters = new Array();
formParameters["new_multiselectpicklist"]  = formContext.getAttribute("new_multiselectpicklist").getValue();

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

Even a hard code assignment getting the same error:即使是硬代码分配也会出现相同的错误:

formParameters["new_multiselectpicklist"]  = [962080001, 962080002];

Edit :编辑

The above line should be like this to make it work.上面的行应该是这样才能使其工作。

formParameters["new_multiselectpicklist"]  = "[962080001, 962080002]";

I tried this alternate option using extraqs and it worked.我使用extraqs尝试了这个替代选项,它起作用了。

https://mycrmdev.crm.dynamics.com/main.aspx?etn=my_entity&pagetype=entityrecord&extraqs=new_multiselectpicklist=[962080001, 962080002]

I got fix the issue by replacing below source code line:我通过替换下面的源代码行解决了这个问题:

Existing现存的

formParameters["new_multiselectpicklist"] = formContext.getAttribute("new_multiselectpicklist").getValue();

Updated更新

formParameters["new_multiselectpicklist"] = "["+formContext.getAttribute("new_multiselectpicklist").getValue()+"]";

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

相关问题 netsuite suitescript 2.0版如何设置多选字段的值? - How to set value for the multi-select field using netsuite suitescript 2.0 version? 在多选表单字段上获取或设置值 - Get or Set Value(s) on A Multi-select Form Field 在 Dynamics 365 XRM Web API 中创建记录时无法设置多选选项字段 - Cannot set multi-select option field when creating record in Dynamics 365 XRM Web API Javascript / MS Dynamics CRM 2016:使用确认框更改选项集字段的值 - Javascript / MS Dynamics CRM 2016: Changing value of option set field using confirm box 如何通过JavaScript查询获取SharePoint多选字段的选定值 - How to get the selected value(s) of a SharePoint Multi-select field via JavaScript query 在 MVC 中设置多选下拉菜单的选定值 - Set the selected value of a multi-select drop down in MVC 如何在JavaScript中使用Base64String值设置Dynamics CRM / 365字段 - How to set a Dynamics CRM/365 field with Base64String value in JavaScript 如何使用javascript以编程方式设置多选框元素的值(复数)? - How do I programatically set the values (plural) of a multi-select box element using javascript? 如何在Dynamics CRM 2013中设置复合材料领域的重点? - How to set focus for a composite field in dynamics crm 2013? 如何为多选选取器设置多个选定值? - How to set multiple selected values for multi-select picker?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM