Dynamics 365 自定义渠道的步骤
阅读原文时间:2023年09月05日阅读:5

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

标准消息模板效果:

2.导出解决方案,往XML增加一个关系【EntityRelationship】
https://learn.microsoft.com/zh-cn/dynamics365/marketing/real-time-marketing-define-custom-channel-instance

注意:导出的解决方案,需要包含实体【msdyn_channelinstance】

示例:

OneToMany 0 1.0.0.0 0 msdyn_ChannelInstance new_flashinfosmschannel NoCascade RemoveLink NoCascade NoCascade NoCascade ¨C14C ¨C15C ¨C16C ¨C17C ¨C18C

3.写插件代码&注册上去&在CRM创建customer api,比如创建的new_flashinfosms_customapi

4.在代码创建自定义渠道

///

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

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章