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的主要内容,如果未能解决你的问题,请参考以下文章

csharp CRM 2016 C ## C ##OptionSets #MoussaElAnnan

csharp CRM 2015-2016 C#Helper #Teams #Sharing#CRM2016 #MoussaElAnnan

csharp CRM 2016 #Workflows#CRM2016 #MoussaElAnnan

csharp CRM 2016 #UnitTests#CRM2016 #MoussaElAnnan

csharp CRM 2016 #Client #Connection #CrmServiceClient#CRM2016 #MoussaElAnnan

csharp C# - 简单的SerialPort单例类|示例:https://heiswayi.github.io/2016/csharp-simple-serialport-singleton-c