我目前正在处理升级项目 Dynamics 2011->2016,对于以下代码,如果选项集中尚未定义该值,则在 Dynamics 2016 中,addOption() 函数似乎不起作用。使用下面的代码确实将值添加到选项集中,但无法选择该选项!有没有办法解决这个问题而不必在字段的选项集中静态添加选项?
PopulateCaseTemplateRecords = function () {
//Fetch case template records
var fetchXml =
"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
+ "<entity name='new_casetemplate'>"
+ "<attribute name='new_name' />"
+ "<filter type='and'>"
+ "<condition attribute='statecode' operator='eq' value='0' />"
+ "<condition attribute='ownerid' operator='eq-userteams' />"
+ "</filter>"
+ "</entity>"
+ "</fetch>";
//retrieve case templates using asynch call to webapi v8.0
return WebAPI.Proxy.Fetch("new_casetemplates", fetchXml).then(function (retrievedCaseTemplate) {
if (retrievedCaseTemplate) {
if (retrievedCaseTemplate.length >= 1) {
Xrm.Page.getControl("new_case_template").clearOptions();
//Populate the Case template option set on Case
for (var i = 0; i < retrievedCaseTemplate.length; i++) {
var option = new Option();
option.text = retrievedCaseTemplate[i].new_name;
option.value = i;
//Add the new option, Does not work in Dynamics 2016 if option not defined in optionset!
Xrm.Page.getControl("new_case_template").addOption(option);
}
}
}
});
}