Knowledge found and lost while working with Microsoft Dynamics CRM
RSS icon Home icon
  • CRM 4 Metadata: Working with Labels

    Posted on April 23rd, 2008 mitch Print Print 1 comment

    As you know, CRM 4.0 introduced multi-language features into the product.  This means a slight change in the way we retrieve metadata related to Entity names.

    The DisplayName property for an Entity has been changed slightly to ensure that you always have access to the localized version of the Entity name.  A sub-property called UserLocLabel has been added to retrieve the label for the language of the current user.

    The only issue is sometimes that value does not exist ( a very rare event, but you need to code for it anyway ).

    Modifying code from the CRM 4.0 SDK, I've created the following method to return either the localized label for the Entity or just the logical name, should the actual label not exist:

    private string RetrieveDisplayName(EntityMetadata entity)
    {
        string displayName = string.Empty;
    
        if (entity.DisplayName.UserLocLabel != null)
        {
            displayName = entity.DisplayName.UserLocLabel.Label.ToString();
        }
        else
        {
            displayName = entity.LogicalName.ToString();
        }
    
        return displayName;
    }
    

    Customization, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 3.00 out of 5)
    Loading ... Loading ...
    2,470 views
     

    One response to “CRM 4 Metadata: Working with Labels”

    1. [...] CRM 4 Metadata: Working with Labels [...]

    Leave a reply