You will often want to run a report on a specific record. This recipe will show you how to set the record that the report will use to execute.
Create a new report by following the Using the Report Generation Wizard recipe.
Save and close the report.
Create a new codeunit from Object Manager.
Add the following global variable:
Name
Type
Subtype
Customer
Record
Customer
Add the following code to the
OnRun
trigger:Customer.FINDFIRST; Customer.SETRANGE("No.", Customer."No."); REPORT.RUN(REPORT::"Report on Record", TRUE, FALSE, Customer);
Save and close the codeunit.
The FINDFIRST
in this example is used here just so we have some data to work with. It is not necessary for you to implement this example. We use this data to apply a filter for the first customer number in the table.
Next comes the important part. NAV has a built-in variable named REPORT
that has several methods associated with it. One of these is the RUN()
method...