Query the Description Value of a Picklist RRS feed

  • Question

  • I am trying to get the value from the Description field of a picklist in CRM, this is what I am using to get the Label value, how would I change it to get the Description Value?

    RetrieveAttributeRequest request = new RetrieveAttributeRequest();
    request.EntityLogicalName = "opportunity";
    request.LogicalName = "country";
    RetrieveAttributeResponse response = (RetrieveAttributeResponse)orgService.Execute(request);
    PicklistAttributeMetadata picklist = (PicklistAttributeMetadata)response.AttributeMetadata;
    foreach (OptionMetadata option in picklist.OptionSet.Options)
            string picklistlabel =  option.Label.UserLocalizedLabel.Label.ToString();
            if (p.Column_16.ToString().ToUpper() == picklistlabel.ToString().ToUpper())
                     countryid= option.Value;


    Saturday, October 15, 2011 7:02 PM


All replies

  • Hello,

    As far as I remember following code would return you the description:


    string description = picklist.Description.UserLocalizedLabel.Label;

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Follow Andriy on Twitter
    Saturday, October 15, 2011 8:12 PM
  • Thanks! I think it's close but not quite right. That gives me the Description of the Entity. So if the pick list is called "Country" and the description of the picklist "Country" is "List of Countries" it gives back "List of Countries".

    I want to get the Description of the values in the picklist.

    So if I have the value in a picklist such as

    Label: United States

    Value: 1

    Description: US

    I want to pull back the US.


    Saturday, October 15, 2011 8:34 PM
  • Label Property of OptionMetadata should return you Label 




    MaKeer | myencounterwithcrm.wordpress.com | CRM2011 User Settings Utility | CRM2011 Lookup Preview
    • Proposed as answer by Makarand Keer Monday, October 17, 2011 7:29 AM
    • Marked as answer by CrazyeD1583 Monday, October 17, 2011 8:18 PM
    Saturday, October 15, 2011 9:09 PM