topic hubReporting & Analyticsofficial - Microsoftreviewed - checked by Opus

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

Videos, posts and code changes

Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.

Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.

What Learn documents here 7 Learn pages