The latest release of the CRM 2011 SDK includes an extension to the CrmSvcUtil to generate OptionSet enumerations. Previously, the tool only generated enums for the StateCode attributes, leaving it as a manual task to create your own enums for any OptionSet values you needed.
Using the extension has never been simpler:
- Using Visual Studio 2010, compile the project found at:
sdk\samplecode\cs\crmsvcutilextensions\generatepicklistenums
- Edit the 'generateoptionsets.bat' file in the bin\Debug folder, replacing the /url: parameter with the url of your own CRM server.
- Double click the 'generateoptionsets.bat', and wait…
- You'll see an 'OptionSets.cs' file created in the Debug folder.
You simply need to include this file in any of your projects and use when setting OptionSet values, being sure to cast as (int).
Sweet!