How to get the count of number of pages printed on to SSRS report [AX 2012 , X++]

Friends,

Recently, I came across an interesting requirement on the reports in AX 2012. If the total number of pages that gets rendered to the report is more than some X pages, the report should get saved to pdf, if not send it as an email.

Tricky part is how do I get the number of pages [page count] after the report got rendered. I tried to get the number of pages before rendering the report but was unsuccessful by using the adapter class and getNumberOfPages() method.

Finally, I found a solution. On Controller classes there is a method by name “reportViewerRefreshComplete” which can be overridden. This method gets triggered once the data has been rendered on to report viewer.

Override the “reportViewerRefreshComplete” method on any controller class and add the below code. This will help to get the count of printed physical pages on to report.

public void reportViewerRefreshComplete(SRSReportExecutionInfo _executionInfo)

{

    int page;

    super(_executionInfo);

 

    page = this.getReportContract().parmReportExecutionInfo().parmPrintedPhysicalPages();

    info("Total number of pages:" + int2str(page));

}

Below is the infolog with the counter of pages, after the report data got rendered on to report viewer.

image

Happy Dax6’ng.

Sreenath Reddy

sree

Advertisements

3 Responses to “How to get the count of number of pages printed on to SSRS report [AX 2012 , X++]”

  1. gangadhar Says:

    Hi

    I have desinged a report in Ax2012 using controller and DP class. This report needs to be accessed from

    Enterprise portal. But i have seen that reports using controller class cannot be accessed from

    Enterprise portal. Is there any solution for this ? so that the report can be shown in Enterprise

    portal.

    Thanks in Advance

  2. Sebastian Says:

    Thanks!!, It was very useful

  3. Vikram Reddy Says:

    Hi Srinath,
    May i know, how did you manage to generate the report in PDF based on number of pages because teh method reportViewerRefreshComplete will be executed in last but print settings will be done in preRunModifyContract method which will be called first.

    It would be great if you can provide a code snippet or let me know if there are any standard reports which is using page numbers for printing the report in diffrent formats.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: