public static string GetOptionSetValue_Label(IOrganizationService service,string enName,string attrName,
int value)
{
RetrieveAttributeRequest request = new RetrieveAttributeRequest() {
EntityLogicalName = enName,
LogicalName = attrName
};
RetrieveAttributeResponse response = (RetrieveAttributeResponse)service.Execute(request);
OptionMetadataCollection options =
((PicklistAttributeMetadata)response.AttributeMetadata).OptionSet.Options;
OptionMetadata option = options.Where(a => a.Value == value).FirstOrDefault();
if (option != null)
{
return option.Label.UserLocalizedLabel.Label;
}
return string.Empty;
}
int value)
{
RetrieveAttributeRequest request = new RetrieveAttributeRequest() {
EntityLogicalName = enName,
LogicalName = attrName
};
RetrieveAttributeResponse response = (RetrieveAttributeResponse)service.Execute(request);
OptionMetadataCollection options =
((PicklistAttributeMetadata)response.AttributeMetadata).OptionSet.Options;
OptionMetadata option = options.Where(a => a.Value == value).FirstOrDefault();
if (option != null)
{
return option.Label.UserLocalizedLabel.Label;
}
return string.Empty;
}