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”];
if(entity.Contains(“address1_addresstypecode”)){
string addressTypeCodeLabel = entity.FormattedValues[“address1_addresstypecode”];
entity.Attributes[“address1_city”] = addressTypeCodeLabel;
service.Update(entity);}
}
http://community.dynamics.com/crm/b/crmmitchmilam/archive/2013/04/18/crm-sdk-nugget-entity-formattedvalues-property.aspx
Hope it helps.
Filed under: CRM, CRM 2011, CRM 2013, Microsoft Dynamics CRM Tagged: CRM, CRM 2011, Microsoft Dynamics CRM

This was originally posted here.
*This post is locked for comments