首页 > 解决方案 > 如何通过 Acumatica 代码为电子邮件活动添加通知模板

问题描述

用户要求是创建一个新的操作按钮以从销售订单屏幕发送电子邮件,当用户单击发送电子邮件时,我们将重定向到电子邮件活动屏幕,对于正文,当我保存此电子邮件活动时,我还需要通过代码传递通知模板那么这个活动应该在“活动”选项卡下的“联系人”屏幕上创建。

为什么联系人屏幕在销售订单中我们有一个自定义字段作为联系人,它是强制性的,所以用户想在联系人屏幕上创建这个活动我有一个代码,直到为联系人创建活动但添加销售订单详细信息,因为通知模板不是当我手动添加该模板时工作,我在正文中看到空白值 bcz 此活动在联系人下创建,因此我得到订单通知模板的空白,下面是我的代码

public PXAction<SOOrder> createBSEmail;
        [PXUIField(DisplayName = "Send Email", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
        [PXButton]
        public void CreateBSEmail()
        {
            ProcessBSEmail();
        }

        private void ProcessBSEmail()
        {
            if (Base.Document.Current != null)
            {
                SOOrderExt rowext = Base.Document.Current.GetExtension<SOOrderExt>();
                if (rowext != null)
                {
                    var targetGraph = PXGraph.CreateInstance<CREmailActivityMaint>();
                    var message = targetGraph.Message.Insert();
                    if (rowext.UsrKWContactID != null)
                    {                        
                        Contact con = PXSelectReadonly<Contact, Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(Base, rowext.UsrKWContactID);
                        if (con != null)
                        {                            
                            message.RefNoteID = con.NoteID;
                            message.BAccountID = con.BAccountID;
                            message.ContactID = con.ContactID;
                            //message.NoteID = con.NoteID;
                            message.IsIncome = false;
                            message.Subject = "Test Subjext";
                            message.MailTo = con.EMail != null ? con.EMail : string.Empty;
                                targetGraph.Message.Update(targetGraph.Message.Current);
                                throw new PXRedirectRequiredException(targetGraph, true, "Email") { Mode = PXBaseRedirectException.WindowMode.NewWindow };
}
                    }
                }
            }
        }


Also, here if i pass salesorder noteid then i am able to get the values for the order notification template when i add it, but then the activity is creating for the order not to the contact.

So how i can resolve this i need to create the activity for the contact and through code i need to pass order details using notification template.


Thanks in advance.

标签: acumaticaacumatica-kb

解决方案


推荐阅读