Solved

Convert Reports to Notification Template

  • 7 December 2020
  • 3 replies
  • 565 views

Userlevel 3
Badge

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

icon

Best answer by Hughes Beausejour 7 December 2020, 16:25

View original

3 replies

Userlevel 5
Badge +2

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();

 

 
 
Userlevel 3
Badge

 

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?

Userlevel 5
Badge +2

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


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved