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 codeunit from Object Designer.
Then add the following global variables:
Name
Type
Subtype
Customer
Record
Customer
Write the following code in the
OnRun
trigger of the codeunit:Customer.FINDFIRST; Customer.SETRANGE("No.", Customer."No."); REPORT.RUN(REPORT::"Customer List", TRUE, FALSE, Customer);
Save and close the codeunit.
The FINDFIRST
value in this example is used here so that we have some data to work with. It is not necessary 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 that takes four parameters. The first parameter is the ID of the report to run...