Tuesday, May 27, 2008

Change the appearance of printed report ranges

In AX you can order selected reports asking the system to print the ranges of your query.

To try this, go to Accounts Receivable / Reports / Base data / Customer.

  • Click Select
  • Click Print Options
  • Check the “Print ranges” check box.

The report header ends up looking something like this example:

Technically this is a fine solution, but it’s not very sexy. So how do you go about changing this section? Take a look at the method \Classes\SysReportRun\buildPrintRanges. This is where AX on the fly builds a new report section with the needed fields and it executes the section to print the requested information.

For a regular no-nonse report like the Customer report, this feature is called from the report template behind the report: \Reports\Report Templates\InternalList\PageHeader:PgHdr_1\Methods\executeSection:

public void executeSection()
If you switch the two lines in this method, you will get the ranges printed under the regular page header, which I think is a bit nicer:

You can add the same lines to your own reports that may not use this template, as long as it is called from the page header section.

With a few lines of additional code in \Classes\SysReportRun\buildPrintRanges you can create cool effects (well, semi-cool):

This will produce a result like this (assuming you have also changed the order of the lines in \Reports\Report Templates\InternalList\PageHeader:PgHdr_1\Methods\executeSection as described above):

1 comment:

Mikko said...

I am interested in printing the report ranges also for my own report with Generated Design (not only for autodesigned), but this function is disabled.

How could I achieve this?