{"title":"Report.SaveAs(Integer, Text, ReportFormat, var OutStream [, RecordRef]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/report/report-saveas-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/report/report-saveas-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/report/report-saveas-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Runs a specific report without a request page and saves the report as a PDF, Excel, Word, HTML, or XML file.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Report.SaveAs(Integer, Text, ReportFormat, var OutStream [, RecordRef]) Method","slug":"reportsaveasinteger-text-reportformat-var-outstream-recordref-method","at":0,"chars":3408},{"level":2,"title":"Syntax","slug":"syntax","at":449,"chars":152},{"level":2,"title":"Parameters","slug":"parameters","at":601,"chars":750},{"level":2,"title":"Return Value","slug":"return-value","at":1351,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":1589,"chars":1211},{"level":3,"title":"Error conditions","slug":"error-conditions","at":2478,"chars":322},{"level":2,"title":"Example (robust coding)","slug":"example-robust-coding","at":2800,"chars":474},{"level":2,"title":"Related information","slug":"related-information","at":3274,"chars":134}],"text":"# Report.SaveAs(Integer, Text, ReportFormat, var OutStream [, RecordRef]) Method\n> Version: _Available or changed with runtime version 1.0._\nRuns 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.\n## Syntax\n```al\n[Ok := ]  Report.SaveAs(Number: Integer, Parameters: Text, Format: ReportFormat, var OutStream: OutStream [, RecordRef: RecordRef])\n```\n## Parameters\nNumber\nType: ../integer/integer-data-type\nThe ID of the report that you want to save. If the report that you specify does not exist, then a run-time error occurs.\nParameters\nType: ../text/text-data-type\nA 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.\nFormat\nType: ../reportformat/reportformat-option\nThe type of file to save the report as. The following options are supported: Pdf, Excel, Word, and XML.\nOutStream\nType: ../outstream/outstream-data-type\nThe stream to which to write a report.\n*[Optional] RecordRef*\nType: ../recordref/recordref-data-type\nThe RecordRef that refers to the table in which you want to find a record.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue 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.\n## Remarks\nYou typically use this method together with the report-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.\nFor a simple example that illustrates how to use the SaveAs method, see the example in the report-runrequestpage-method method article.\n> NOTE\n> 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.\n### Error conditions\nThe method can fail in the following two ways:\n If no report exists with an object id as specified in \"Number\".\n If the string of request page parameters as XML specified in \"Parameters\" can't be parsed as valid request page data.\nIf the report you specify doesn't exist, then a runtime error occurs.\n## Example (robust coding)\nThis example shows how to use the static SaveAs method in a safe way (where no errors occur).\n```al\nvar\n    RequestPageParameters: Text;\n    Format: ReportFormat;\n    Stream: OutStream;\nbegin\n    // setup RequestPageParameters, Format, and Stream variables\n\n    // Note that by using the scope operator (::), you catch at compile time if MyReport does not exist\n    Report.SaveAs(Report::MyReport, RequestPageParameters, Format, Stream);\nend;\n```\n## Related information\nreport-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}