CRM 2011 Get OptionSetValue Value through Label

Sometimes we want to be able to get the OptionSetValue value from the label itself. One way is to use the metadata request and loop through it but this is a cumbersome way.

The easier way is to put those OptionSetValue data into an enum like this:


We use Description Attribute for the Label so that it supports string format.

Then we use this helper method:


And there you go. You can easily get the value like this:



Hope this helps,
Andreas

Comments

  1. Great post! I also use the metadata request to get OptionSetValue value.

    ReplyDelete

Post a Comment

Popular posts from this blog

SharePoint 2013 anonymous access add attachments to list item

CRM Plugin - Parent and Child Pipeline

Sitecore custom publish agent from specific node and at a specific time