Report.SaveAs(Text, ReportFormat, var OutStream [, RecordRef]) Method

Version: Available or changed with runtime version 1.0.

Runs a specific report without a request page and saves the report as a PDF, Excel, Word, or XML file. Instead of using the request page to obtain parameters at runtime, the method gets the parameter values as an input parameter string, typically from the return value of a RunRequestPage method call.


[Ok := ]  Report.SaveAs(Parameters: Text, Format: ReportFormat, var OutStream: OutStream [, RecordRef: RecordRef])


 Type: Report
An instance of the Report data type.

 Type: Text
A string of request page parameters as XML to use to run the report. The parameter string is retrieved from the return value a RunRequestPage method call.

 Type: ReportFormat
The type of file to save the report as. The following options are supported: Pdf, Excel, Word, and XML.

 Type: OutStream
The stream to which to write a report.

[Optional] RecordRef
 Type: RecordRef
The RecordRef that refers to the table in which you want to find a record.

Return Value

[Optional] Ok
 Type: Boolean
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.


You typically use this method together with the RunRequestPage Method method. The RunRequestPage method runs a report request page without actually running the report, but instead, it returns the parameters that are set on the request page as a string. You can then call the SaveAs method to get the parameter string and save the report to a file of the specified format.

For a simple example that illustrates how to use the SaveAs method, see the example in the RunRequestPage Method method topic.


By default, when a report uses an RDL report layout at runtime, fonts are embedded in the generated PDF. You can specify whether fonts are embedded in the PDF for RDL reports by changing the Report PDF Font Embedding setting in the Dynamics 365 Business Central service instance configuration or changing the PDFFontEmbedding property in report objects.

Error conditions

The method can fail in the following ways:

  • If the string of request page parameters as XML specified in "Parameters" can't be parsed as valid request page data.

See also

Report Data Type
Get Started with AL
Developing Extensions