This documentation is archived and is not being maintained.

Using the Labels in the Metadata Web Service

Forefront
banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Labels are localized strings displayed to users in the client applications. They are implemented by using the CrmLabel class, which supports the new Microsoft Dynamics CRM 4.0 Language Pack. Strings that are displayed to users, such as entity display names or options in a picklist can be stored in multiple languages. In this manner, the user can select which language should be displayed in forms and views in Microsoft Dynamics CRM.

The following table lists all the metadata that uses the CrmLabel class.

Metadata propertyDescription
AttributeMetadata.DescriptionThe description for an attribute.
AttributeMetadata.DisplayNameThe display name for an attribute.
EntityMetadata.DescriptionThe description for an entity.
EntityMetadata.DisplayCollectionNameThe plural display name for an entity.
EntityMetadata.DisplayNameThe display name for an entity.
ManyToManyMetadata.Entity1AssociatedMenuLabelThe label used for the first entity in a many-to-many relationship.
ManyToManyMetadata.Entity2AssociatedMenuLabelThe label used for the second entity in a many-to-many relationship.
OneToManyMetadata.AssociatedMenuLabelThe label used for the related entity in a one-to-many relationship.
Option.LabelThe label used for an option in a picklist, state, or status attribute.

The CrmLabel class can store one string for each installed language. This array is the CrmLabel.LocLabels property. There must always be a label stored for the base language. The labels for other languages can be null. If the user chooses to display the UI in a language and a label does not have a string for that language, the label for the base language is used.

The CrmLabel.UserLocLabel property can be used to quickly retrieve the label for the language chosen by the user context when the label is retrieved.

Helper Method to Create a Single Label

The following code sample can be used as a helper to create a single label.

Example

[C#]
static CrmLabel CreateSingleLabel(string sLabel, int iLcid)
{
   LocLabel[] labels = new LocLabel[1];
   labels[0] = new CrmLabel();
   labels[0].Label = sLabel;
   labels[0].LanguageCode = new CrmNumber();
   labels[0].LanguageCode.Value = iLcid;
   CrmLabel label = new CrmLabel();
   label.LocLabels = labels;
   return label;
}

See Also

Other Resources


© 2010 Microsoft Corporation. All rights reserved.


Show: