{"id":13005,"date":"2018-09-26T18:34:50","date_gmt":"2018-09-26T13:04:50","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=13005"},"modified":"2022-09-02T15:30:10","modified_gmt":"2022-09-02T10:00:10","slug":"multi-select-option-set-field-in-dynamics-365-v9-0","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2018\/09\/multi-select-option-set-field-in-dynamics-365-v9-0\/","title":{"rendered":"Multi-Select Option Set field in Dynamics 365 V9.0"},"content":{"rendered":"<h2 style=\"text-align: justify;\"><strong>Introduction:<\/strong><\/h2>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">In this blog we will discuss how to Get, Set, Add and Remove options in Multi-Select Option Set.<\/p>\n<p style=\"text-align: justify;\"><strong>Recently<\/strong>, we came across below scenario,<\/p>\n<p style=\"text-align: justify;\">Where, User wants to update Multi Select Option Set from another option set programmatically and also Ad &amp; Remove options from Multi Select Option Set<\/p>\n<ul>\n<li>\n<h2><strong>Retrieve Multi-Select Option Set and copy into another option set programmatically:<\/strong><\/h2>\n<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">Entity entity = _service.Retrieve(\"account\", new Guid(old RecordId), new ColumnSet(\"new_multioption\"));\r\nEntity accountEntity = new Entity (\"account\", new Guid(New RecordId));\r\n\r\naccountEntity[\"new_multioption\"] = entity.GetAttributeValue&lt;OptionSetValueCollection&gt;(\"new_multioption\");<\/pre>\n<ul>\n<li>\n<h2><strong>Set Multi Select Option Set programmatically:<\/strong><\/h2>\n<\/li>\n<\/ul>\n<p><strong>For Single value<\/strong><\/p>\n<pre class=\"lang:default decode:true \">OptionSetValueCollection collectionOptionSetValues = new OptionSetValueCollection();\r\n\r\nOptionSetValue optionSet = new OptionSetValue(optionsetValue);\r\n\r\ncollectionOptionSetValues.Add(optionSet);\r\n\r\nentityAccount[\"new_multioption\"] = collectionOptionSetValues;\r\n_service.Update(entityAccount); \r\n<\/pre>\n<p><strong>For multiple values <\/strong><\/p>\n<pre class=\"lang:default decode:true\">string[] arr = { collection of option set value };\r\n\r\nforeach(var item in arr)\r\n{\r\ncollectionOptionSetValues.Add(new OptionSetValue(Convert.ToInt32(item)));\r\n}\r\n\r\nentityAccount[\"new_multioption\"] = collectionOptionSetValues;\r\n_service.Update(entityAccount);<\/pre>\n<ul>\n<li>\n<h2><strong>Remove Multi-Select Option Set programmatically:<\/strong><\/h2>\n<\/li>\n<\/ul>\n<p><strong>Remove single value<\/strong><\/p>\n<pre class=\"lang:default decode:true \">formContext.getControl(multioptionset).removeOption(optionsetvalue);<\/pre>\n<p><strong>Remove multiple values<\/strong><\/p>\n<pre class=\"lang:default decode:true \">string[] arr = { collection of option set value };\r\n\r\nforeach(var item in arr)\r\n{\r\n\tformContext.getControl(multioptionset).removeOption(item);\r\n}\r\n<\/pre>\n<ul>\n<li>\n<h2><strong>Add new options in Multi Select Option Set programmatically:<\/strong><\/h2>\n<\/li>\n<\/ul>\n<p><strong>Add Single option value<\/strong><\/p>\n<pre class=\"lang:default decode:true\">formContext.getControl(multioptionset).addOption(new Xrm.OptionSetItem(value, text), position);<\/pre>\n<p><strong>Add Multiple option value<\/strong><\/p>\n<pre class=\"lang:default decode:true\">var position = 0;\r\nvar optArr = [Collection of option set ];\r\n\r\nfor (var i = optArr.length - 1; i &gt;= 0; i--) {\r\nformContext.getControl(multioptionset).addOption(new Xrm.OptionSetItem(optArr [i].value, optArr [i].text), position++);\r\n\t}<\/pre>\n<h2><strong>Conclusion:<\/strong><\/h2>\n<p>Using the code above user can Get, Set, Add and Remove Multi Select Option Set programmatically in Dynamics 365 v9.0.<\/p>\n<h2 style=\"text-align: left;\"><div class=\"su-heading su-heading-style-default su-heading-align-center\" id=\"\" style=\"font-size:15px;margin-bottom:5px\"><div class=\"su-heading-inner\">Generate Your Own New Leads Within Microsoft Dynamics 365 CRM<\/div><\/div><\/h2>\n<p><em>Contact us for a <a href=\"https:\/\/www.maplytics.com\/maplytics-download\/?utm_source=highvisits&amp;utm_medium=technicalblog&amp;utm_campaign=hMaplytics\" target=\"_blank\" rel=\"noopener\">demo<\/a> to know more about how <a href=\"https:\/\/www.maplytics.com\/?utm_source=highvisits&amp;utm_medium=technicalblog&amp;utm_campaign=hMaplytics\" target=\"_blank\" rel=\"noopener\">Maplytics<\/a> can help you to generate new leads from within Microsoft Dynamics 365 CRM.<\/em><\/p>\n<p><em><a href=\"https:\/\/www.maplytics.com\/?utm_source=highvisits&amp;utm_medium=technicalblog&amp;utm_campaign=hMaplytics\" target=\"_blank\" rel=\"noopener\">Maplytics<\/a> is a 5-star rated, preferred business app on the <a href=\"https:\/\/appsource.microsoft.com\/en-us\/product\/dynamics-365\/inogic.f6f3c73f-29de-4fa8-a396-87ea8a07b6c4?tab=Overview\" target=\"_blank\" rel=\"noopener\">Microsoft AppSource<\/a> that is Certified for Microsoft Dynamics 365 (CfMD) and comes with powerful features like Appointment Planning, Sales Routing, Territory Management, Heat Maps, Geo-analytical Dashboards and more that empower organizations to add more value to their CRM data, improve sales &amp; service processes, and achieve high ROI.<\/em><\/p>\n<p><em>Get your <a href=\"https:\/\/www.maplytics.com\/maplytics-download\/?utm_source=highvisits&amp;utm_medium=technicalblog&amp;utm_campaign=hMaplytics\" target=\"_blank\" rel=\"noopener\">free trial<\/a> from our Website or <a href=\"https:\/\/appsource.microsoft.com\/en-us\/product\/dynamics-365\/inogic.f6f3c73f-29de-4fa8-a396-87ea8a07b6c4?tab=Overview\" target=\"_blank\" rel=\"noopener\">Microsoft AppSource<\/a>!<\/em><\/p>\n<p><em>&#8216;If data is the new oil, location intelligence is ??\u201d<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: 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\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2018\/09\/multi-select-option-set-field-in-dynamics-365-v9-0\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":13009,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[16,18,19,27],"tags":[1226,1227,1228,1229],"class_list":["post-13005","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365","category-dynamics-365-v9-2","category-dynamics-crm","category-field-service-2","tag-multi-select-option-set-field","tag-multi-select-option-set-field-dynamics-365","tag-multi-select-option-set-field-dynamics-crm","tag-multi-select-option-set-field-microsoft-dynamics-365"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/13005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=13005"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/13005\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/13009"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=13005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=13005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=13005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}