Report.SaveAs 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, HTML, 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.

Syntax

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

Parameters

Number
 Type: Integer
The ID of the report that you want to save. If the report that you specify does not exist, then a run-time error occurs.

Parameters
 Type: String
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.

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

OutStream
 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.

Remarks

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, 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 example in the RunRequestPage Method method topic.

Note

By default, when a report uses an RDLC report layout at runtime, fonts are embedded in the generated PDF. You can specify whether fonts are embedded in the PDF for RDLC 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.

See Also

Report Data Type
Getting Started with AL
Developing Extensions