Get and Set Multiselect Option set field values through Javascript

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();


function SetMultiSelect(executionContext) {
var formContext = executionContext.getFormContext();
//Option values with comma separates
//Overwrites the Existing Selected Values


That’s. It. Enjoy 🙂

5 thoughts on “Get and Set Multiselect Option set field values through Javascript

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

    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!


  2. 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 ?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s