标签:crm2011创建自定义实体entity crm创建实体 crm2011自定义开发 crm2011 crm
using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata;
using Microsoft.Crm.Sdk.Messages;
/// <summary>
/// crm创建自定义实体
/// </summary>
public class CreateEntityHelper
{
public void Create(IOrganizationService service)
{
//构造Request对象
CreateEntityRequest request = new CreateEntityRequest();
//注释
request.HasNotes = false;
//是否是活动实体
request.HasActivities = false;
//主字段
StringAttributeMetadata stringAttr = new StringAttributeMetadata();
//字段名称
stringAttr.LogicalName = "new_name";
//架构名称
stringAttr.SchemaName = "new_name";
//显示中文名称
stringAttr.DisplayName = new Label("名称", 2052);
//字段的最大长度
stringAttr.MaxLength = 200;
//需求级别
stringAttr.RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None);
request.PrimaryAttribute = stringAttr;
EntityMetadata entity = new EntityMetadata();
//表名
entity.LogicalName = "new_autonumber_values";
//架构名称
entity.SchemaName = "new_autonumber_values";
//显示名称
entity.DisplayName = new Label("流水码", 2052);
//复数名称
entity.DisplayCollectionName = new Label("流水码", 2052);
//描述
entity.Description = new Label("流水码",2052);
//所有权:用户实体
entity.OwnershipType = OwnershipTypes.UserOwned;
//审核
entity.IsAuditEnabled = new BooleanManagedProperty(false);
//重复检测
entity.IsDuplicateDetectionEnabled = new BooleanManagedProperty(true);
//连接
entity.IsConnectionsEnabled = new BooleanManagedProperty(false);
//发送电子邮件
entity.IsActivityParty = false;
//邮件合并
entity.IsMailMergeEnabled = new BooleanManagedProperty(false);
//文档管理
entity.IsDocumentManagementEnabled = false;
//队列
entity.IsValidForQueue = new BooleanManagedProperty(false);
//Mobile Express
entity.IsVisibleInMobile = new BooleanManagedProperty(false);
request.Entity = entity;
service.Execute(request);
System.Console.WriteLine("创建实体成功!");
service.Execute(new PublishAllXmlRequest());
System.Console.WriteLine("发布成功!");
}
}
结果:
crm2011创建自定义实体Entity,布布扣,bubuko.com
标签:crm2011创建自定义实体entity crm创建实体 crm2011自定义开发 crm2011 crm
原文地址:http://blog.csdn.net/y_f123/article/details/30459635