Modifier

Partager via


Report.RunModal(Integer [, Boolean] [, Boolean] [, var Record]) Method

Version: Available or changed with runtime version 1.0.

Loads and executes the report that you specify.

Syntax

 Report.RunModal(Number: Integer [, RequestWindow: Boolean] [, SystemPrinter: Boolean] [, var Record: Record])

Parameters

Number
 Type: Integer
The ID of the report that you want to run.

[Optional] RequestWindow
 Type: Boolean
Specifies whether the request window for the report will be displayed. The request window is part of the report object.

[Optional] SystemPrinter
 Type: Boolean
Specifies whether to use the default Windows printer or use table 78, Printer Selection, to find the correct printer for this report.

[Optional] Record
 Type: Record
Specifies which record to use in the report. Any filters that are attached to the record that you specify are used.

Remarks

Use this method, or the Report.Run Method, if you do not know the specific report that you want to run when you are designing your application. If you do know the specific report that you want to run, then you can use the RunModal Method or the Run Method.

The request page is run modally when you use this method. However, when the user chooses Preview on the request page, the Print Preview page does not run modally.

If the report you specify does not exist, then a runtime error occurs.

Note

Internet browsers can only handle one file per request. Therefore, with the Web client, if this method is called in a repetitive statement (or loop) that generates multiple files, only the last file will be sent to the browser. Alternatively, when designing for the Web client, bundle the files in an archive file (.zip), for example, by using the methods found in codeunit 419 File Management. For more details about this design pattern, see Multi-File Download. The methods in codeunit 419 aren't external, therefore can't be used in extensions. Instead, when developing extensions in AL, use the external methods of codeunit 425 Data Compression. The approach is similar.

Example: Using Report::<object ID> syntax

As mentioned previously, the Report.RunModal method throws a runtime error if no report with the supplied object ID exists. If you know the report object, a safe way to call Report.RunModal is to use the Report::<object identifier> syntax because the compiler will tell you if the report object doesn't exist.

begin
    // If MyReport does not exist, then this will fail at compile time, not at runtime
    Report.RunModal(Report::MyReport);
end;

Example 2

This example shows how to run a report. This example displays the request window and sends the report to the printer selected through the Printer Selection table.

Report.RunModal(1001);  

Example 3

This example shows how to run a report. This example skips the request window, starts the report immediately, and sends the report to the printer that is selected in the Printer Selection table.

Report.RunModal(1001, False);  

Example 4

This example shows how to run a report. This example skips the request window and starts the report immediately. It sends the report to the system printer instead of the printer that is selected in the Printer Selection table.

Report.RunModal(1001, False, True);  

RunModal (instance) Method
Report Data Type
Get Started with AL
Developing Extensions