Query the Description Value of a Picklist

倖福魔咒の 提交于 2019-12-12 04:45:59

问题


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;
            }
    }

Thanks!


回答1:


You can find the description for a specific option in a optionset by accessing the Description property.

Like this:

string description = option.Description.UserLocalizedLabel.Label.ToString();

Here is a list of members exposed by the PicklistAttributeMetadata.



来源:https://stackoverflow.com/questions/7779984/query-the-description-value-of-a-picklist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!