码迷,mamicode.com
首页 > 其他好文 > 详细

crm2011创建Boolean类型字段

时间:2014-06-10 13:38:26      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:crm2011创建boolean类型字段   crm2011创建字段   crm2011开发   crm2011   

     using System;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Messages;
    using Microsoft.Xrm.Sdk.Metadata;

    /// <summary>
    /// Boolean
    /// </summary>
    public class CreateBooleanAttributeHelper
    {
        private string entityName = "new_class";

        public void Create(IOrganizationService service)
        {
            CreateAttributeRequest request = new CreateAttributeRequest();
            //关联的实体名称
            request.EntityName = entityName;
            BooleanAttributeMetadata boolAttribute = new BooleanAttributeMetadata();
            //字段名称
            boolAttribute.LogicalName = "new_boolvalue";
            //架构名称
            boolAttribute.SchemaName = "new_boolvalue";
            //显示中文名称
            boolAttribute.DisplayName = new Label("Boolean字段", 2052);
            //描述
            boolAttribute.Description = new Label("Boolean字段", 2052);
            //需求级别
            boolAttribute.RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None);
            //字段安全性
            boolAttribute.IsSecured = false;
            //审核
            boolAttribute.IsAuditEnabled = new BooleanManagedProperty(false);
            //选项
            BooleanOptionSetMetadata optionSet = new BooleanOptionSetMetadata();
            optionSet.FalseOption = new OptionMetadata(new Label("False", 2052), 0);
            optionSet.TrueOption = new OptionMetadata(new Label("True", 2052), 1);
            boolAttribute.OptionSet = optionSet;
            //默认值
            boolAttribute.DefaultValue = false;

            request.Attribute = boolAttribute;

            service.Execute(request);
        }
    }

 

结果:

bubuko.com,布布扣

crm2011创建Boolean类型字段,布布扣,bubuko.com

crm2011创建Boolean类型字段

标签:crm2011创建boolean类型字段   crm2011创建字段   crm2011开发   crm2011   

原文地址:http://blog.csdn.net/y_f123/article/details/29557079

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!