1.创建2个实体:渠道【new_flashinfosmschannel】、消息模板(配置窗体)
注意:如果想用标准消息模板,可以不用创建消息模板
标准消息模板效果:
2.导出解决方案,往XML增加一个关系【EntityRelationship】
https://learn.microsoft.com/zh-cn/dynamics365/marketing/real-time-marketing-define-custom-channel-instance
注意:导出的解决方案,需要包含实体【msdyn_channelinstance】
示例:
<EntityRelationship Name="msdyn_ChannelInstance_extendedentityid_new_flashinfosmschannel"> <EntityRelationshipType>OneToMany</EntityRelationshipType> <IsCustomizable>0</IsCustomizable> <IntroducedVersion>1.0.0.0</IntroducedVersion> <IsHierarchical>0</IsHierarchical> <ReferencingEntityName>msdyn_ChannelInstance</ReferencingEntityName> <ReferencedEntityName>new_flashinfosmschannel</ReferencedEntityName> <CascadeAssign>NoCascade</CascadeAssign> <CascadeDelete>RemoveLink</CascadeDelete> <CascadeReparent>NoCascade</CascadeReparent> <CascadeShare>NoCascade</CascadeShare> <CascadeUnshare>NoCascade</CascadeUnshare> <CascadeRollupView>NoCascade</CascadeRollupView> <IsValidForAdvancedFind>1</IsValidForAdvancedFind> <ReferencingAttributeName>msdyn_extendedentityId</ReferencingAttributeName> <RelationshipDescription> <Descriptions> <Description description="" languagecode="1033" /> </Descriptions> </RelationshipDescription> <EntityRelationshipRoles> <EntityRelationshipRole> <NavPaneDisplayOption>UseCollectionName</NavPaneDisplayOption> <NavPaneArea>Details</NavPaneArea> <NavPaneOrder>10000</NavPaneOrder> <NavigationPropertyName>msdyn_extendedentityid_new_flashinfosmschannel</NavigationPropertyName> <RelationshipRoleType>1</RelationshipRoleType> </EntityRelationshipRole> <EntityRelationshipRole> <NavigationPropertyName>msdyn_ChannelInstance_extendedentityid_new_flashinfosmschannel</NavigationPropertyName> <RelationshipRoleType>0</RelationshipRoleType> </EntityRelationshipRole> </EntityRelationshipRoles> </EntityRelationship>
3.写插件代码&注册上去&在CRM创建customer api,比如创建的new_flashinfosms_customapi
4.在代码创建自定义渠道
/// <summary> /// 渠道定义 /// </summary> /// <param name="service"></param> /// <returns></returns> public static Guid Insert_msdyn_channeldefinitions(IOrganizationService service) { Entity entity = new Entity("msdyn_channeldefinition"); entity.Id = Guid.NewGuid();// entity["msdyn_name"] = "Flashinfo SMS Channel"; entity["msdyn_displayname"] = "Flashinfo SMS Channel"; entity["msdyn_description"] = "Flashinfo SMS Channel"; entity["msdyn_channeltype"] = "Custom"; entity["msdyn_outboundendpointurltemplate"] = "/new_flashinfosms_customapi"; entity["msdyn_hasinbound"] = false; entity["msdyn_hasdeliveryreceipt"] = true; entity["msdyn_supportsaccount"] = false; entity["msdyn_channeldefinitionexternalentity"] = "new_flashinfosmschannel"; entity["msdyn_channeldefinitionexternalformid"] = "2054e3cb-e2fb-4d0a-bdde-cc51982da65d"; //必须小写,是实体new_flashinfosmschannel的主窗体ID entity["msdyn_messageformid"] = "9af480f8-a1b8-422a-9e4e-62d95a952ccf"; //可以为null,代表使用标准模板效果 var id = service.Create(entity); return id; } /// <summary> /// 消息定义 /// </summary> /// <param name="service"></param> /// <param name="cid"></param> public static void Insert_msdyn_channelmessageparts(IOrganizationService service, Guid cid) { Entity entity = new Entity("msdyn_channelmessagepart"); entity.Id = Guid.NewGuid();// entity["msdyn_name"] = "text";// 消息部分的名称 entity["msdyn_displayname"] = "text";// 显示名称 entity["msdyn_description"] = "text";// 说明 entity["msdyn_channeldefinitionid"] = new EntityReference("msdyn_channeldefinition", cid);// 渠道定义 ID entity["msdyn_type"] = new OptionSetValue(192350000);// 渠道类型 entity["msdyn_isrequired"] = true;// 指示是否需要此部分 entity["msdyn_maxlength"] = 1000;// 部分的最大长度 var id = service.Create(entity); }
调用:
var id = Insert_msdyn_channeldefinitions(adminService); Insert_msdyn_channelmessageparts(adminService, id);
5.在自定义渠道,就能看到新增的渠道
标签:flashinfosmschannel,自定义,Marketing,entity,NoCascade,msdyn,new,Dynamics,id From: https://www.cnblogs.com/parkerchen/p/17678334.html