crm2011创建Boolean类型字段
2014-06-09 09:46
399 查看
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);
}
}
结果:
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创建多行文本类型的字段
- crm2011创建Lookup类型的字段
- crm2011创建浮点类型的字段
- crm2011创建货币Money类型的字段
- crm2011创建货币Money类型的字段
- crm2011创建Picklist类型的字段
- crm2011创建DateTime类型的字段
- crm2011创建int类型字段
- CRM2011 更改字段类型,又不删除原有数据
- crm2011的字段类型
- crm2011字段类型
- CRM中选择一个lookup类型带出该记录其他字段的值
- android学习意外第二季——在类型"R"中创建字段"id"
- PyCon 2011 - Hidden Treasures of the Python Standard Library - 自定义sqlite3数据表字段数据类型
- sql server2005在创建字段的时候选择数据类型的参考
- 在Access中创建表及如何指定字段类型
- MS CRM 2011中PartyList类型字段的实例化
- Access sql语句创建表及字段类型
- Android 数据库创建字段时的数据类型
- SQL 2000创建表的时候设置某一字段为自动增长的类型