After many frustrated google searches, I have been unable to find an out of the box solution for importing option sets into a Microsoft CRM 2015 environment. There are a few articles out there about importing records with the values, then deleting the records, but this does not allow you to control the numeric value of the import. Looking at the hours of mindless manual entry that was staring me in the face for a client demo, I made one more search into MSDN in hopes that I could put together a simple piece of code that might be able to do it. Luckily enough I found that Microsoft has included a simple code example in the SDK that shows how to work with option sets programmatically ( With a little work I was able to come up with a generic re-usable function that can be passed a dictionary and turn it into a global option set.

Here is what the full function looks like:

All you need to provide:

  • Your crm connection
  • The logical name you would want for the option set
  • The display name for the option set
  • A dictionary<int, string> of the keys and values you want the option set to contain
  • Your language code value (it defaults to 1033 – English)

Just use your preferred method of loading the data into the dictionary and you are good to go.


Like this post? Share it!