In NAV 2017 Emailing the PDF by running the report using Report.SAVEASPDF is now not allowed in NAV 2018. The reason is that temporary server file as not allowed to be saved for some security reasons. Thus this blog demonstrates the workaround solution for this issue.


NAV 2018


1. Concept:

  • With respect to NAV 2018, Microsoft says that Emailing the attachments should be done using Streams. Thus, we’ve to convert the PDF generated by running the report into a stream and pass the stream as an attachment (https://community.dynamics.com/nav/f/34/t/270046).
  • Before running the report, the data needs to be passed appropriately to the Report. Report.RUNMODAL method cannot be used as running report requires XML Parameters. For this, we make use of XMLParameters that are sent to the report through either a request page or as XML Text which contains a list of parameters to be passed and then the report is run.

2. Procedure:
Step1: Generate the XMLParameters(Text) using the RUNREQUESTPAGE method and copy the results.

REQUESTPAGE is used to set the filters prior to running the report. The filters selected are passed to the report in XML format.

Value in XMLParameter: Here, Rec.Contract No. is the primary filter to be passed to the report.

Step2: Create the Instream and Outstream variables and a temporary table having BLOB field.

Create the OutStream variable for the BLOB field of the Temporary Table.

Save the data of OutStream variable using Report.SaveAs method.

Copy the data of the BLOB field to Instream

Step 3: Pass the attachment as a Stream using Instream

Note: Perform the Step 1 only if there is any filter to be applied to the report.


This workaround is to be used where the Report.SAVEASPDF cannot be used because this method is not allowed in AL.

The post Workaround to Report.SAVEASPDF in NAV 2018 appeared first on CloudFronts - Microsoft Dynamics 365 | Power BI | Azure.