Bearbeiten

Freigeben über


Report.Run(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.Run(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.RunModal Method, if you don't know the specific report that you want to run when you're designing your application. If you do know the specific report that you want to run, then you can use the Run Method or the RunModal Method.

If the report you specify doesn't 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.

Printing

The parameter SystemPrinter is only used for on-premises scenarios (print on server). Here, the Business Central server will use the default printer on the server if you use SystemPrinter = true, otherwise it uses the printer selection.

For the online version of Business Central, users can use printer extension and browser print.

Example: Using Report::<object ID> syntax

As mentioned previously, the Report.Run 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.Run is to use the Report::<object identifier> syntax because the compiler will tell you if the report object doesn't exist.

begin
    Report.Run(Report::MyReport);
end;

Example 1

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

Report.Run(1001);  

Example 2

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's selected in the Printer Selection table.

Report.Run(1001, False);  

Example 3

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.Run(1001, False, True);  

Example 4

This example shows how to run a report for which you specify a record. This example displays the request window and sends the report to the system printer.

var
    MyRec: Record Customer;
begin
    MyRec.FindLast;  
    MyRec.SetRecFilter;  
    Report.Run(101, True, True, MyRec);  
end;

Report Data Type
Get Started with AL
Developing Extensions