Attach order acknowledgement to email in BPM

The solution was to switch to rundirect instead of submittoagent

1 Like

Simple than expected!!!

According to my requirement, calling “Submit To Agent” itself enough to trigger email with attachment. Here my below simple snippet,

      var orderNum = this.myOrderNum; // assign function variable to local variable
      
	  //call business object
	  this.CallService<Erp.Contracts.SalesOrderAckSvcContract>(soa => {
      
	  Erp.Tablesets.SalesOrderAckTableset dsSOA = new Erp.Tablesets.SalesOrderAckTableset();
      
	  //define function params
      dsSOA = soa.GetNewParameters();
      dsSOA.SalesOrderAckParam[0].OrderNum = orderNum;
      dsSOA.SalesOrderAckParam[0].OrderList = orderNum.ToString();
      dsSOA.SalesOrderAckParam[0].AutoAction = "SSRSPrint";
      dsSOA.SalesOrderAckParam[0].ReportStyleNum = 1002; //your report style number
      dsSOA.SalesOrderAckParam[0].DateFormat = "m/d/yyyy";
      dsSOA.SalesOrderAckParam[0].NumericFormat = ",.";
      dsSOA.SalesOrderAckParam[0].ReportCultureCode = "en-US";
      dsSOA.SalesOrderAckParam[0].ReportCurrencyCode = "USD";
      dsSOA.SalesOrderAckParam[0].SSRSRenderFormat = "PDF";
      dsSOA.SalesOrderAckParam[0].FaxSubject = "***********";   //this is your email subject
      dsSOA.SalesOrderAckParam[0].EMailTo = "****.*****@*****.****";   //your TO email address
      dsSOA.SalesOrderAckParam[0].EMailBody = "*********************"; //email body
      dsSOA.SalesOrderAckParam[0].AttachmentType = "PDF";
      dsSOA.SalesOrderAckParam[0].RowMod = "A";
      soa.SubmitToAgent(dsSOA, "SystemTaskAgent", 0, 0, "Erp.UIRpt.SalesOrderAck");
      soa.Dispose();
      });

Executing this through function will automatically trigger the email with attachment. :clinking_glasses:

1 Like

Yes, if you do not need to do any custom processing to the email, SubmitToAgent is more than sufficient with the proper parameters to let Epicor take care of it for you.

RunDirect is useful when you want to retrieve the reportBytes and DIY.

1 Like

I read back through my notes and my main requirement was because the version we were on did not support HTML formatting in APR emails. But I’m under the impression it does now. I’ve never gotten back to the project (must not have been important enough) but if I ever do, I’d use Auto Print and handle it with APR.

2 Likes

I’m not aware that it does, but I will have to check!