Get OptionSet Label using FormattedValues property of Entity in Plugin in CRM

The easiest way to get the Label for the option set in plugin is using the FormattedValues property of the Entity.

The Post Create plugin on Contact record getting the label for the address type field.

if (context.InputParameters.Contains(“Target”) && 
context.InputParameters[“Target”] is Entity){

// Obtain the target entity from the input parmameters. 

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


string addressTypeCodeLabel = entity.FormattedValues[“address1_addresstypecode”];

entity.Attributes[“address1_city”] = addressTypeCodeLabel;



Hope it helps.

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

Share your thoughts

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