0
votes

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
What are you doing with these optionset values that you've added, that aren't actually stored in CRM?Daryl
We are capturing onchange of this optionset and capturing the selected value then we send the selected data to our other system via API. This data in drop down also comes from the same system.Ashish Jain
Ashish, your words "send the selected data to our other system via API" means to me that you are are trying to integrate another system by dynamically updating controls inside a CRM form, correct?Eccountable
Yes, we are doing it via Plugin. But we are using an entity field to show this data, though this field is not being saved. Anyways, I have fixed this issue via a Web Resource control added to system.Ashish Jain
The same problem and I have no idea...Sergii Gorkun

1 Answers

1
votes

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