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);
}
},