Report trigger implementation flow

Completed

As a developer, you can use triggers in reports and other objects. Triggers can be considered as predefined procedures that run when certain events occur.

In reports, triggers are typically used to perform calculations and verification. Triggers let you control how data is selected and retrieved in a more complex and effective way than you can achieve by using properties.

In a report, triggers can be divided into three categories:

  • Report

  • Data item

  • Request page

Examples of report triggers include OnPreReport, which contains statements that are run immediately before the report is run, and OnPostReport, which contains statements that are run immediately before the report implementation completes.

When you run a report, the report triggers are called in a specific order. The following illustration describes the order of report triggers.

Diagram of the report triggers called in a specific order.

These triggers apply to the actual report:

  • OnInitReport - Runs when the report is loaded.

  • OnPreReport - Runs before the report is run but after the RequestPage has been run.

  • OnPostReport - Runs after the report has run but not if the report was stopped manually or by the QUIT method.

These triggers apply to each data item on the report:

  • OnPreDataItem - Runs before the data item is processed but after the associated variable has been initialized.

  • OnAfterGetRecord - Runs when a record has been retrieved from the table.

  • OnPostDataItem - Runs when the data item has been iterated for the last time.

When you initiate the report run, the OnInitReport trigger is called. If the OnInitReport trigger does not end processing of the report, then the request page for the report is run, if it's defined. The page triggers for the request page are called. On the request page, you can select the options that you want for this report. You can also decide to cancel the report run. If you decide to continue, then the OnPreReport trigger is called. At this point, no data has yet been processed. When the OnPreReport trigger has been run, the first data item is processed, provided that the processing of the report was not ended in the OnPreReport trigger.

When the first data item has been processed, the next data item, if any exist, is processed in the same way. When no more data items are left, the OnPostReport trigger is called to conduct necessary post processing, for example, removing temporary files.

Before the first record is retrieved, the OnPreDataItem trigger is called, and after the last record has been processed, the OnPostDataItem trigger is called.

Between these two triggers, the data item records are processed. Processing a record means running the record triggers and creating data. After a record is retrieved from the data item, the OnAfterGetRecord trigger is called.

If an indented data item exists, then the records in this data item are processed.

When records are no longer available for processing in a data item, control returns to the point from which processing was initiated. For an indented data item, this parameter means the next record of the data item on the next highest level. If the data item is already on the highest level, then control returns to the report.