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

Thanks

Ajay

Advertisements

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