Tuesday, 3 June 2014

handle SSRS reports which will take long time to run with the messages to the user [Dynamics AX 2012– preRunValidate() method]

How to handle SSRS reports which will take long time to run with the messages to the user [Dynamics AX 2012– preRunValidate() method]


Friends,
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. [msdn]
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. [msdn]
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. [msdn]
In this case, we should not run the report and therefore, should return an SrsReportPreRunState::Error enumeration value with the error message.
In AX 2012, SSRS reports , through SrsReportRunController we can easily let the user know that the report will take more time with warnings or error messages through preRunValidate method.
Example : General Journals report
Let me take the standard example of Print journal from General Ledger >> Reports >> Journal >> Print journal.
I am using standard LedgerJournalController class to help you understand preRunValidate method: this validates container before running the report. We have to 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. However this is customizable based on your requirement.
image
Now let us run this report as shown below : Click on the Ok Button.
image
Here comes the confirmation Box: If your report is long running, it may time-out. Do you want to continue?
In order to resolve/by pass this confirmation Box, a developer can change the macro #define.warningLimit to greater value
Example : #define.warningLimit(2000);
image
Now lets increase the row count : to 1000001.
Please note: Remove hardcoded values later. This is hardcoded only for the sake of demo/Walk through
image
Let us run the report One more time as shown below.
image
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 the preRunValidate 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);
image

No comments:

Post a Comment

Labels

#veryusefulcode (1) AIF (8) AOT Maps (1) Args (1) Ax 2009 Reports (2) AX 2012 navigation (1) Ax 2012 Interview Questions (1) AX 7 (2) AX Architecture (1) Ax Backup (1) AX Workflow (2) AX2012 (1) AX2012 R2 (1) Ax2012R3 (1) AX2012R3 Dynamics Connector Step by Step Installation and Configuration (1) AX2012R3 EP Step by Step Installation and Configuration EP R3 (1) AX2012R3 HelpServer Step by Step Installation and Configuration (1) AX2012R3 Rapid Start Connector Step by Step Installation and Configuration (1) AX2012R3 Report Server and Analysis Server Step by Step Installation and Configuration (1) AX7 (1) Best practices (1) Blocking user to enter (1) Collection Classes (1) Container (1) D365FO (3) Data Migration Frame Work ax 2012R3 (1) Deleting duplicate Record from Table – Ax2012 (1) Delivery due date notification workflow in Ax 2012 (1) Development Steps EP (1) Dimensions (1) DIXF (1) DMF in Ax 2012 R3 (1) Dynamics Ax 2012 Interview Questions (1) DYNAMICS AX 2012 INTERVIEW QUESTIONS PART 2 (1) DYNAMICS AX 7 (1) EDT relation Migration Tool (1) EP AX 2012 (1) Ep Lookup (1) Error (1) Event Handler (1) F5 (1) File Handling (4) Filter on AX2012 Listpage (1) filtering (2) financial dimensions in AX 2012 (3) form (1) images (1) Installation and Configration (4) Installation and Configuration (11) Installation of Management Reporter 2012 for AX 2012 (1) Interaction class in ax 2012 (1) Interview Question (1) Interview Questions For Ax 2012 (1) Invent DIm (1) Jobs (2) license (1) List page and form menuitem enable code (1) Methods (1) microsoft Dynamics AX 365FO (1) Number Sequence Generation – AX 2012 (5) Number Sequence2012 (1) OLTP-OLAP (1) Passing Args (1) Passing form caller and menu item caller in ax 2012 (1) Passing Multiple Records Args (1) Posting in Ax 2012 (1) POSTING PURCHASE ORDER (1) Query (1) Query Filter Form (2) Query Ranges in X++ (1) Question and Answer (1) Report (1) Reports Controller class (1) RLS in ax 2009 (1) SALES ORDER IMPORT/EXPORT FRAMEWORK BY DMF (1) Security (1) security roles (1) Security Sysqueryrangeutil (1) Sharepoint 2016 (1) SQL SERVER (1) SSRS (2) SSRS Reports Controller class (2) Table collections & Virtual company (1) Time (1) TIPS AND TRICKS (1) Web service AIF (3) Web Services on IIS (AIF) Step by Step Installation and Configuration (1) workflow ax2012 (1) Workflow installation (1) Workflow Method (3) X++ (1)