Home > CRM 2011, Plug-Ins > Read Optionset value in Plugin CRM 2011

Read Optionset value in Plugin CRM 2011


  Below is the sample code to read Picklist value (i.e., OptionSet Value) in CRM 2011

if (context.InputParameters.Contains(“Target”) && context.InputParameters[“Target”] isEntity)


currEntity = (Entity)context.InputParameters[“Target”];


int statusValue = -1;

string statusText=string.empty;

if (currEntity .Attributes.Contains(“statecode”))


OptionSetValue optionState = currEntity .Attributes[“statecode”] as OptionSetValue;

statusValue = optionTimesheetState.Value;

statusText = optionTimesheetState.Text;


Hope it helps 🙂

  1. March 26, 2012 at 9:01 PM

    Great it is working ….

  2. Rokas
    May 18, 2012 at 6:41 PM

    Thanks, it works 🙂

  3. BRMD
    May 29, 2012 at 3:56 PM

    Thanks for your post but I don’t find The “Text” method…

    • Debbie
      August 15, 2013 at 10:24 PM

      I’m also receiving the “does not contain a definition for ‘text'” error. What am i missing?

      • Jack
        February 19, 2014 at 11:05 PM

        Me too I have the same issue with Text. Did you find a solution please?

  4. Jack
    February 20, 2014 at 3:34 AM

    Here is a very good solution to retrieve optionSet Text when you have the value and vice versa :

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: