Below Code is taken from this post ,
private string
GetPickListText(string entityName, string attributeName, int
optionSetValue)
{
string AttributeName = attributeName;
string EntityLogicalName = entityName;
RetrieveEntityRequest
retrieveBankAccountEntityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.All,
LogicalName = EntityLogicalName
};
RetrieveEntityResponse
retrieveBankAccountEntityResponse = (RetrieveEntityResponse)_serviceContext.Execute(retrieveBankAccountEntityRequest);
Microsoft.Xrm.Sdk.Metadata.EntityMetadata
metadata = retrieveBankAccountEntityResponse.EntityMetadata;
Microsoft.Xrm.Sdk.Metadata.PicklistAttributeMetadata
picklistMetadata = metadata.Attributes.FirstOrDefault(attribute => String.Equals(attribute.LogicalName,
attributeName, StringComparison.OrdinalIgnoreCase))
as Microsoft.Xrm.Sdk.Metadata.PicklistAttributeMetadata;
Microsoft.Xrm.Sdk.Metadata.OptionSetMetadata
options = picklistMetadata.OptionSet;
IList<OptionMetadata>
picklistOption = (from o in options.Options
where o.Value.Value == optionSetValue
select o).ToList();
string picklistLabel = (picklistOption.First()).Label.UserLocalizedLabel.Label;
return picklistLabel;
}
Hope this helps,
Yusuf
Hope this helps,
Yusuf
No comments:
Post a Comment