Skip to main content
Solved

Convert Reports to Notification Template

  • December 7, 2020
  • 3 replies
  • 609 views

Forum|alt.badge.img

Hej!

Is there any known way to maybe convert a already made Report File (.rpx) to HTML, so we can use it as notification template? Our Customer would like to send E-Mails with their Design but without having the main report attached, instead letting the E-Mail itself being the “Report”.

Help would be appreciated!
Thanks

Best answer by Hughes Beausejour

Report definition file (RPX) can’t be converted to HTML or to Notification Template because the formats are incompatible. However the reports render it’s output in HTML by default.

 

So you can follow instructions on how to render report file:

https://asiablog.acumatica.com/2017/05/get-pdf-file-from-report-using-code.html

 

And specify the HTML output option:

byte[] data = PX.Reports.Mail.Message.GenerateReport(reportNode, ReportProcessor.FilterHtml).First();

 

To include the report in a email along with a template you need to send the email template programmatically:

https://asiablog.acumatica.com/2017/05/sending-notification-template-from.html

 

And add the report  HTML output to the body of the email:

TemplateNotificationGenerator sender = TemplateNotificationGenerator.Create(order, notification.NotificationID.Value);
sender.MailAccountId = (notification.NFrom.HasValue) ? notification.NFrom.Value : PX.Data.EP.MailAccountManager.DefaultMailAccountID;
sender.RefNoteID = order.NoteID;
sender.Owner = order.OwnerID;
sender.To = contact.Email;
sender.Body = sender.Body + [... HTML Report Output ...];
sent |= sender.Send().Any();

 

 
 
View original
Did this topic help you find an answer to your question?

3 replies

Hughes Beausejour
Acumatica Employee
Forum|alt.badge.img+2
  • Acumatica Developer Support Team
  • 91 replies
  • Answer
  • December 7, 2020

Report definition file (RPX) can’t be converted to HTML or to Notification Template because the formats are incompatible. However the reports render it’s output in HTML by default.

 

So you can follow instructions on how to render report file:

https://asiablog.acumatica.com/2017/05/get-pdf-file-from-report-using-code.html

 

And specify the HTML output option:

byte[] data = PX.Reports.Mail.Message.GenerateReport(reportNode, ReportProcessor.FilterHtml).First();

 

To include the report in a email along with a template you need to send the email template programmatically:

https://asiablog.acumatica.com/2017/05/sending-notification-template-from.html

 

And add the report  HTML output to the body of the email:

TemplateNotificationGenerator sender = TemplateNotificationGenerator.Create(order, notification.NotificationID.Value);
sender.MailAccountId = (notification.NFrom.HasValue) ? notification.NFrom.Value : PX.Data.EP.MailAccountManager.DefaultMailAccountID;
sender.RefNoteID = order.NoteID;
sender.Owner = order.OwnerID;
sender.To = contact.Email;
sender.Body = sender.Body + [... HTML Report Output ...];
sent |= sender.Send().Any();

 

 
 

Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 117 replies
  • December 7, 2020
Hughes Beausejour wrote:

 

To include the report in a email along with a template you need to send the email template programmatically:

 

 
 

What exactly do you mean by that? 
In what matter would it include the report in the e-mail? 
My current approach would be to take the HTML Output and paste it in the notification template, so that the design is ready and done easily. Because if this works, i would only need to change some fields and stuff, but not the whole design.

Do you maybe have an example of the process?


Hughes Beausejour
Acumatica Employee
Forum|alt.badge.img+2
  • Acumatica Developer Support Team
  • 91 replies
  • December 7, 2020

In what matter would it include the report in the e-mail? 

 

I mean that the report output will not appear in the email message body if you don’t make the changes required for that to happen. The alternative would be to ask Acumatica to create the customization for you which is a billed service.

 

Do you maybe have an example of the process?

 

The examples are in the two links I provided. It’s a two part process, first you generate a report in HTML (1) and then you append the rendered report HTML to the email body (2).

  1. https://asiablog.acumatica.com/2017/05/get-pdf-file-from-report-using-code.html

  2. https://asiablog.acumatica.com/2017/05/sending-notification-template-from.html

 

The examples need two modifications for your scenario:

  1. Generate report in HTML format:
    byte[] data = PX.Reports.Mail.Message.GenerateReport(reportNode, ReportProcessor.FilterHtml).First();
     
  2. Append the HTML content in the email body:
    sender.Body = sender.Body + [... HTML Report Output ...];

 

My current approach would be to take the HTML Output and paste it in the notification template, so that the design is ready and done easily.

 

If the HTML content is always the same then you can try pasting it in the template but it makes no sense to put a RPX file in a notification template because a template is not a report generator.

 

Because if this works, i would only need to change some fields and stuff, but not the whole design.

 

It’s really not clear how changing field and stuff would result in dynamic reports shown in email body. To get a dynamic report content in the email body you need to add it manually which means programming is required. This doesn’t affect the notification template.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings