Multi-Select Option Set field in Dynamics 365 V9.0

By | September 26, 2018


With the release of Dynamics 365 v9.0 Microsoft introduced a new data type i.e. Multi Select Option Set with the help of this we can select more than one option set in Dynamics 365.

Multi-Select Option Set has a list of options and we can select more than one option from the list on selecting checkboxes. i.e we can search option set from the list of option.

In this blog we will discuss how to Get, Set, Add and Remove options in Multi-Select Option Set.

Recently, we came across below scenario,

Where, User wants to update Multi Select Option Set from another option set programmatically and also Ad & Remove options from Multi Select Option Set

  • Retrieve Multi-Select Option Set and copy into another option set programmatically:

Entity entity = _service.Retrieve("account", new Guid(old RecordId), new ColumnSet("new_multioption"));
Entity accountEntity = new Entity ("account", new Guid(New RecordId));

accountEntity["new_multioption"] = entity.GetAttributeValue<OptionSetValueCollection>("new_multioption");
  • Set Multi Select Option Set programmatically:

For Single value

OptionSetValueCollection collectionOptionSetValues = new OptionSetValueCollection();

OptionSetValue optionSet = new OptionSetValue(optionsetValue);


entityAccount["new_multioption"] = collectionOptionSetValues;

For multiple values

string[] arr = { collection of option set value };

foreach(var item in arr)
collectionOptionSetValues.Add(new OptionSetValue(Convert.ToInt32(item)));

entityAccount["new_multioption"] = collectionOptionSetValues;
  • Remove Multi-Select Option Set programmatically:

Remove single value


Remove multiple values

string[] arr = { collection of option set value };

foreach(var item in arr)
  • Add new options in Multi Select Option Set programmatically:

Add Single option value

formContext.getControl(multioptionset).addOption(new Xrm.OptionSetItem(value, text), position);

Add Multiple option value

var position = 0;
var optArr = [Collection of option set ];

for (var i = optArr.length - 1; i >= 0; i--) {
formContext.getControl(multioptionset).addOption(new Xrm.OptionSetItem(optArr [i].value, optArr [i].text), position++);


Using the code above user can Get, Set, Add and Remove Multi Select Option Set programmatically in Dynamics 365 v9.0.


2 thoughts on “Multi-Select Option Set field in Dynamics 365 V9.0

  1. Kiran


    While trying to remove couple of values using “removeoption” in multi option sets during onChange of another field I think I found a bug in the control
    The values get removed from the multi option set but does not actually reflect in the UI. Those options are still visible but cannot be selected. If I try “Select All” only the values which I didn’t remove get selected. Can you please let me know if you also encountered this issue and suggest any work around?

    1. inogic Post author


      Yes, I did encounter the issue and below is workaround for the same:

      When we remove SelectedOptionset value in MultiOptionset, at that time it actually gets removed from the list but not from form UI, for that we have to clear selected option set value first and then remove list of option from Multi Option Set.

      Find the below code to clear selected options value in Multi option set.
      formContext.getAttribute(“new_multioptionset”).setValue(null); // is used to clear selected options on multi optionset

      Hope this helps and feel free to ask in case you have any query regarding the same.



Leave a Reply

Your email address will not be published. Required fields are marked *