CRM 2011 StringMap Table

Technical Reflections

Fields in a CRM entity record are often based on a pick list. Should you need to query the SQL database directly to extract information these will come out not as the text based descriptive values, but a code such as 0, 1, or 2. To retrieve the associated descriptive information, a join to the StringMapBase table is required. A rough SQL query might be something like so:

This works fine for most items, but some such as statecode are used in multiple entities. A join to the MetaDataSchema.Entity table to get the ObjectTypeCode will filter down the records. If you do not the following will result:

Say you wanted to retrieve the values for statecode for the Opportunity entity, you would write query such as this:

The reason for the date filter is that CRM maintains a history of changes to the entities. If a customisation solution has been…

View original post 47 more words

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.