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!
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
.