标签: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);
}
}
结果:
crm2011创建Boolean类型字段,布布扣,bubuko.com
标签:crm2011创建boolean类型字段 crm2011创建字段 crm2011开发 crm2011
原文地址:http://blog.csdn.net/y_f123/article/details/29557079