4

Dynamics 365 Marketing自定义渠道的步骤 - 溜溜球_小钢wan

 1 year ago
source link: https://www.cnblogs.com/parkerchen/p/17678334.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Dynamics 365 Marketing自定义渠道的步骤

Dynamics 365 Marketing 创建自定义渠道:大家知道,微软官方文档,也有很具体的介绍,但是大家发现按照微软的官方介绍,少不了跳坑,这里给大家整理分享一些。

微软官方介绍:https://learn.microsoft.com/en-us/dynamics365/customer-insights/journeys/real-time-marketing-create-custom-channels#create-a-new-custom-channel

1.创建2个实体:渠道【new_flashinfosmschannel】、消息模板(配置窗体)
注意:如果想用标准消息模板,可以不用创建消息模板

标准消息模板效果:

2024897-20230904225211397-710420284.png

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

2024897-20230904224755999-593054468.png

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.在自定义渠道,就能看到新增的渠道

2024897-20230904230008913-1946561848.png

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK