public static string GetoptionsetDescription(string entityName, string attributeName, int optionSetValue, IOrganizationService service)
{
string
AttributeName = attributeName;
string
EntityLogicalName = entityName;
RetrieveEntityRequest retrieveDetails = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.All,
LogicalName = EntityLogicalName
};
RetrieveEntityResponse retrieveEntityResponseObj = (RetrieveEntityResponse)service.Execute(retrieveDetails);
Microsoft.Xrm.Sdk.Metadata.EntityMetadata metadata = retrieveEntityResponseObj.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>
OptionsList = (from o in options.Options
where o.Value.Value ==
optionSetValue
select o).ToList();
string optionsetDescription
= (OptionsList.First()).Description.UserLocalizedLabel.Label;
return
optionsetDescription;
}
Wow it worked , thanks Narender :) Was stucked badly looking for the solution , got resolution here .
ReplyDeleteGood job..now i can retrieve from option set related field details....
ReplyDelete