Day to Day Dynamics CRM going very interestingly with lot of exciting features. One of the interesting features is Multiselect Optionset Field. Through this new datatype we can set multiple option values.
Datatype : MultiSelect Option Set
- Pass Execution Context as a Parameter.
getValue / getText:
function GetMultiSelect(executionContext) { var formContext = executionContext.getFormContext(); //Returns Array of Selected OptionSet Values: [1001,1002,1005 ] var selectedValues = formContext.getAttribute("gb_multiselect").getValue(); //Returns Array of Selected OptionSet Text: ["One", "Two","Six"] var selectedTexts = formContext.getAttribute("gb_multiselect").getText(); }
SetValue:
function SetMultiSelect(executionContext) { var formContext = executionContext.getFormContext(); //Option values with comma separates //Overwrites the Existing Selected Values formContext.getAttribute("gb_multiselect").setValue([1003,1004,1006]); }
That’s. It. Enjoy 🙂
I am trying to set the multiselect option set values using the above code, its not working.
var selectedValues = formContext.getAttribute(“multiselect”).getValue();
console.log(” Value: ” + selectedValues);
var selectedTexts = formContext.getAttribute(“multiselect”).getText();
console.log(” Value: ” + selectedTexts);
formContext.getAttribute(“multiselect”).setValue([1000,1001]);
I am trying to update this field on change of another field. Also I don’t have any business rules set on the multiselect option field.
Kindly help!
LikeLike
when we set values of multiselect option set in javascript, the options gets selected, I want non of them gets selected at UI when setting values in javascript any property you know ?
LikeLike
[…] my previous post contains Get / Set Value to MultiSelect Option set Field  and Limitations of […]
LikeLike
[…] In my previous post contains Get / Set Value to MultiSelect Option set Field. […]
LikeLike
Nice article Balu!!!!
LikeLike