How to handle SSRS reports which will take long time
We know that there are/will be some reports which will take
more time to render due to the many rows/transactions. This post will help you
to show appropriate warning/error messages to the end user while running the
report.
The number of records that are processed by report might be large and the user
experience will be affected, because the client will be locked up if printing
to the screen.
In this case, you might want to return a warning message to the user that
indicates that time to process the report might be long and confirm that they
want to run the report.
Another case could be where the number of records being processed is very large
and a time-out might occur in report processing and clearly, we should not run
this report.
In this case, we should not run the report and therefore,
should return anSrsReportPreRunState::Error enumeration value with the error
message.
In AX 2012, SSRS reports, through SrsReportRunController we can easily let the user know the
report will take more time with warnings or error messages through preRunValidate method.
Example : General Journals
report
Take the standard example of Print journal from General Ledger >> Reports
>> Journal >> Print journal.
Use standard LedgerJournalController class to help you understand preRunValidate method: this validates container
before running the report. Override this method to do custom pre-validation for
any report. Typical use of this method will be to validate if the time taken to
run the report is acceptable.
In this standard example: If the query is going to retrieve
more than 1000 rows, a confirmation Box will be displayed to the user as shown
below.
To get the confirmation box and for the sake of the demo/understanding: I have hardcoded the rows count to 1001 as shown below. There is a new static
method in QueryRun::getQueryRowCount that
will get the row Count of the query.
Please note: Remove hardcoded values
later. This is hardcoded only for the sake of demo/Walk through
Clearly in the below standard example : warning limit is
1000 and error limit is 100000.
The number of records that are processed by report might be large and the user experience will be affected, because the client will be locked up if printing to the screen.
In this case, you might want to return a warning message to the user that indicates that time to process the report might be long and confirm that they want to run the report.
Another case could be where the number of records being processed is very large and a time-out might occur in report processing and clearly, we should not run this report.
Example : General Journals report
Take the standard example of Print journal from General Ledger >> Reports >> Journal >> Print journal.
Use standard LedgerJournalController class to help you understand preRunValidate method: this validates container before running the report. Override this method to do custom pre-validation for any report. Typical use of this method will be to validate if the time taken to run the report is acceptable.
To get the confirmation box and for the sake of the demo/understanding: I have hardcoded the rows count to 1001 as shown below. There is a new static method in QueryRun::getQueryRowCount that will get the row Count of the query.
Please note: Remove hardcoded values later. This is hardcoded only for the sake of demo/Walk through
Run this report as shown below...
Here comes
the confirmation Box:
If your report is long running, it may
time-out. Do you want to continue?
Note: In order to resolve/by pass this confirmation Box, a developer can change the macro #define.warningLimit to greater value
Example : #define.warningLimit(2000);
you can increase the row count : to 1000001.
Let us run the report One more time as shown below.
Here comes
the error message: Running the
report has been cancelled due to the time it will take to run. Adjust the
parameters of the report and retry.
In order to resolve this problem, Increase the ErrorLimit
macro value in thepreRunValidate method.
Please note, it is not recommended to increase as it will
take more time and your box cannot handle load.
Example : #define.ErrorLimit(150000);
Click below
for original post...
-Harry
Hey guys,
ReplyDeleteWhy don't you take some to credit the creator of this article originally before just copying it...
This article was originally written at http://dynamicsaxgyan.wordpress.com/2012/05/21/how-to-handle-ssrs-reports-which-will-take-long-time-to-run-with-the-messages-to-the-user-dynamics-ax-2012-prerunvalidate-method/