[英]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.