Tuesday, April 08, 2014

AX2012 Print multiple reports to screen at the same time

It's common that customer require multiple reports to be printed with one button click. There are many ways to tackle this. The developer can override the click method of the menuitem button to call multiple reports. One can also customize the ReportController class to trigger other reports when run.
However, one characteristic with the above approaches is that when printing to screen, user will need to close the first report before the second one will be shown. To overcome this, we can modify the SrsReportViewer form.

Create a new form method to call another report
private void callSecondReport()
    SecondReportController newController;

    if (controller.parmReportName() == [First report])
            // Print the second report
            newController = new SecondReportController();
             * Prepare the new controller
            // ...

Call the new form method at the end of the form's Run method.
public void run()
   // Standard code
   // ...


Remember the changes above only works when the print destination is Screen. To have consistent behavior on different printing destinations, the changes to SrsReportViewer form has to be done in addition to what was mentioned at the beginning of the post. Furthermore, checkings will be needed such that the second report is not printed twice when print to screen.

This posting is provided "AS IS" with no warranties, and confers no rights.