Generate Early Bound OptionSet enums

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:

  1. Using Visual Studio 2010, compile the project found at:
    sdk\samplecode\cs\crmsvcutilextensions\generatepicklistenums
  2. Edit the 'generateoptionsets.bat' file in the bin\Debug folder, replacing the /url: parameter with the url of your own CRM server.
  3. Double click the 'generateoptionsets.bat', and wait…
  4. 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!

Comments (1) -

  • if all the OptionSet label names are in English, it's ok but
    if they arent English, generated source code  has "unknownlabel" for the enum member attributes

    it works only with
    0x409 = 1033 = "US-EN"=United States' English

Comments are closed