CRM 2013 Dynamic OptionSet issue

主宰稳场 提交于 2019-12-12 10:23:38

问题


I am using CRM 2013 On premise, and in it there is an attribute which has an option set (not global) having text and value as "Dummy Entry" "0". Default Value is unassigned.

My code is to add options in this option set with some business logic. So I can add new options in it via Javascript.

When I am adding Options in it via Javascript, it is not allowing me to change the value lets say

Option1 val1 Option2 val1 is added then it wont allow me to select these values and every-time selecting them will revert to default entry "--" and nothing will change.

But lets say I add "Option1" "0" "Option2" "0"

as text and values, they are shown finely and selecting any of them changes the text to "Dummy Entry".

Basically somehow if the value exists in the list of Options (which are static and not added via JS), it is accepting and selecting it and showing text from it.

If the value is not found in the static option list, it doesnt select anything and show default "--"

I hope I am clear, please let me know in case of any confusion. The following snippet is working in CRM 2011 while not working in CRM 2013.

// testing function
populateBundleLists: function () {
    var bundleListControl = Xrm.Page.getControl("XXX_bundlelist");
    var bundleOptions = bundleListControl.getAttribute().getOptions();
    var bundleOption = bundleOptions[0];
    bundleListControl.clearOptions();

    // add some arbitrary values to control
    for (var i = 1; i <= 7; i++) {
        bundleOption.value = i;
        bundleOption.text = 'Dummy bundle ' + i.toString();
        bundleListControl.addOption(bundleOption, i - 1);  

    }
},

回答1:


CRM stores OptionSets in the entity configuration and will need to know about all of the possible values. You cannot add new options using JS b/c the system will not be able to resolve your new value when someone queries using a different mechanism (Fetch XML, Advanced Find, filtered view, etc).



来源:https://stackoverflow.com/questions/20658554/crm-2013-dynamic-optionset-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!