csharp CRM 2016 C ## C ##OptionSets #MoussaElAnnan
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp CRM 2016 C ## C ##OptionSets #MoussaElAnnan相关的知识,希望对你有一定的参考价值。
//This method will return the label for the LCID of the account the IOrganizationService is using
public static string GetOptionSetValueLabel(string entityName, string fieldName, int optionSetValue, IOrganizationService service)
{
var attReq = new RetrieveAttributeRequest();
attReq.EntityLogicalName = entityName;
attReq.LogicalName = fieldName;
attReq.RetrieveAsIfPublished = true;
var attResponse = (RetrieveAttributeResponse)service.Execute(attReq);
var attMetadata = (EnumAttributeMetadata)attResponse.AttributeMetadata;
return attMetadata.OptionSet.Options.Where(x => x.Value == optionSetValue).FirstOrDefault().Label.UserLocalizedLabel.Label;
}
//This method will return the label for the specified LCID
public static string GetOptionSetValueLabel(string entityName, string fieldName, int optionSetValue, int lcid, IOrganizationService service)
{
var attReq = new RetrieveAttributeRequest();
attReq.EntityLogicalName = entityName;
attReq.LogicalName = fieldName;
attReq.RetrieveAsIfPublished = true;
var attResponse = (RetrieveAttributeResponse)service.Execute(attReq);
var attMetadata = (EnumAttributeMetadata)attResponse.AttributeMetadata;
return attMetadata.OptionSet.Options.Where(x => x.Value == optionSetValue).FirstOrDefault().Label.LocalizedLabels.Where(l => l.LanguageCode == lcid).FirstOrDefault().Label;
}
以上是关于csharp CRM 2016 C ## C ##OptionSets #MoussaElAnnan的主要内容,如果未能解决你的问题,请参考以下文章