Report triggers and events
Report triggers and events in AL for Business Central: events raised during report generation, printing, and export. Answers questions about patching documents, setting up printers, custom rendering, and customizing export filenames.
Path: Development > Programming in the AL language > Developing reports > Report triggers and events · tier official · system reporting · narrative reviewed (checked by Opus)
Overview
This section documents the events a developer can subscribe to in order to change how reports are generated, delivered, and named. The events cover the report life cycle: setting up printers, rendering, intermediate and final document handling, printing, and file naming.
The pages are independent reference topics, one per event. OnAfterDocumentReady and OnAfterIntermediateDocumentReady are for document patching, and the latter works on intermediate artifacts such as XML or Word files. OnCustomDocumentMergerEx handles custom rendering. OnAfterSetupPrinters and OnAfterDocumentPrintReady cover printer extensions. OnGetFilename customizes export file names.
Start with the event that matches your scenario. For a printer extension, read OnAfterSetupPrinters first, then OnAfterDocumentPrintReady. For changes to generated output, begin with OnAfterDocumentReady.
Key points
- OnAfterDocumentPrintReady is raised when a user selects print on a report request page, and is used to send the report to a target extension printer.
- OnAfterDocumentReady lets you modify generated report artifacts before they are saved or printed, by subscribing in the ReportManagement codeunit.
- OnAfterIntermediateDocumentReady intercepts intermediate artifacts such as XML or Word files, for document patching and testing.
- OnAfterSetupPrinters defines printers with payload settings: paper sizes, trays, duplex, color, and default copies.
- OnCustomDocumentMergerEx supports custom rendering using the dataset, layout, and report JSON payload parameters.
- OnGetFilename is an integration event in codeunit 44 ReportManagement for naming PDF, Excel, or Word exports.
- Several events use a report payload and relate to SaveAs, SendTo actions, and print.
Learn pages
- OnAfterDocumentPrintReady Event: Describe the OnAfterDocumentPrintReady Event in Business Central.
- OnAfterDocumentReady Event: Describe the OnAfterDocumentReady Event in Business Central.
- OnAfterIntermediateDocumentReady Event: Describe the OnAfterIntermediateDocumentReady Event in Business Central.
- OnAfterSetupPrinters Event: Describe the OnAfterSetupPrinters Event in Business Central.
- OnCustomDocumentMergerEx event: Describe the OnCustomDocumentMergerEx Event in Business Central.
- OnGetFilename Event: Learn about the OnGetFilename event in Business Central.
- Report Triggers and Runtime Operations: Report triggers in AL for Business Central.
Videos, posts and code changes
Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.
- #183 Add reporting review guidance and evaluation fixtures (code change): “covering report variable clearing, CurrReport control flow, report extensions”
Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.
What Learn documents here 7 Learn pages
- learnOnAfterDocumentPrintReady Event2021-04-01
- learnOnAfterDocumentReady Event2023-03-13
- learnOnAfterIntermediateDocumentReady Event2023-03-10
- learnOnAfterSetupPrinters Event2021-04-01
- learnOnCustomDocumentMergerEx event2023-12-20
- learnOnGetFilename Event2025-06-11
- learnReport Triggers and Runtime Operations2021-05-17