zoukankan      html  css  js  c++  java
  • 9.0 sdk 多选选项集

            public string OptionSetVelueC(IOrganizationService serviceAdmin, Entity entity, string str, string _entityName, int[] i = null)
            {
                if (entity.Attributes.Contains(str))
                {
                    string ss = "";
                    OptionSetValueCollection optionSetValues = entity.Attributes[str] as OptionSetValueCollection;
                    var req = new RetrieveEntityRequest
                    {
                        EntityFilters = EntityFilters.Attributes,
                        LogicalName = _entityName,
                        RetrieveAsIfPublished = true
                    };
                    var resp = (RetrieveEntityResponse)serviceAdmin.Execute(req);
                    var attrInfo = resp.EntityMetadata.Attributes.First(a => a.LogicalName == str);
                    var pick = attrInfo as MultiSelectPicklistAttributeMetadata;
                    foreach (var option in pick.OptionSet.Options)
                    {
                        if (null != i)
                        {
                            if (i.Contains(option.Value.Value))
                            {
                                ss += option.Label.UserLocalizedLabel.Label + ",";
                            }
                        }
                        else
                        {
                            if (optionSetValues.Select(x => x.Value).ToList().Contains(option.Value.Value))
                            {
                                ss += option.Label.UserLocalizedLabel.Label + ",";
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(ss))
                    {
                        ss = ss.Substring(0, ss.Length - 1);
                        return ss;
                    }
                }
                return "";
            }
    

      

  • 相关阅读:
    I Hate It HDU
    线段树为什么要开4倍空间
    敌兵布阵 HDU
    线段树 模板
    线段树原理详解
    HDU5037 Frog
    HDU5187 zhx's contest
    HDU5307 He is Flying
    UOJ#34. 多项式乘法
    Bzoj4766 文艺计算姬
  • 原文地址:https://www.cnblogs.com/ly1998/p/12022612.html
Copyright © 2011-2022 走看看