private string getName(string optionsetName,int val,string entity)
{
try
{
RetrieveAttributeRequest req = new RetrieveAttributeRequest();
req.EntityLogicalName = entity;
req.LogicalName = optionsetName;
RetrieveAttributeResponse res = (RetrieveAttributeResponse)XrmContext.Execute(req);
PicklistAttributeMetadata objPckLstAttMetadata = new PicklistAttributeMetadata();
ICollection<object> objCollection = res.Results.Values;
objPckLstAttMetadata.OptionSet = ((EnumAttributeMetadata)(objCollection.ElementAt(0))).OptionSet;
foreach (var item in objPckLstAttMetadata.OptionSet.Options)
{
if (item.Value==val)
{
return item.Label.LocalizedLabels[0].Label;
}
}
return string.Empty;
}
catch (Exception)
{
return string.Empty;
}
}
Hiç yorum yok:
Yorum Gönder