SSRS Tip: Prevent report execution through controller – Dynamics Ax 2012
What a user might hate to see is a blank report. No matter where the mistake lies the earlier we react the happier the user is. Here today i’m sharing a tip on how you could stop/warn/show a info after the report execution is initiated after the user clicks the “Ok” button in the dialog.
In the example discussed here, the idea is to check preemptively if a query will return a record or not. If no then the report aborts execution.
To implement this, open the controller of your report or create one.
On the controller class, override the method “preRunValidate”
Place the code as shown here. This method is invoked after the user clicks the “Ok” button and before the report is executed. Do not block the super call in this method as it does few other important validations. This method can return an error/warning/info. If it is a warning or error the report aborts further execution.
protected container preRunValidate() { container validateResult = super(); Query firstQuery; int recordcount; firstQuery = this.getFirstQuery(); custStatementCount = QueryRun::getQueryRowCount(firstQuery, 6); if (custStatementCount > 5) { validateResult = [SrsReportPreRunState::Error, "No valid records found for the specified range"]; } return validateResult; }
Standard recommends the method to be used for validating if the report returns a large amount of data.For reference see \Classes\CustAgingReportController\preRunValidate\
For more tips and learning about SSRS – AX 2012 order the book Dynamics AX 2012 Reporting Cookbook authored by me.
Related articles
- SSRS Tip: Speed up RDP based SSRS reports testing in Dynamics Ax 2012
- SSRS Tip: Using labels for dynamic texts in SSRS reports – Dynamics Ax 2012
- SSRS tip: Take care that VS and AX client are in the same layer for SSRS – Dynamics AX 2012
- SSRS tip: How to set the page size for a SSRS report in Dynamics Ax 2012
- SSRS tip: No row message in Dynamics Ax SSRS 2012
- Dynamics Ax 2012 reporting cookbook for SSRS – Dynamics Ax 2012
Dynamics Ax 2012 reporting cookbook for SSRS – Dynamics Ax 2012
Interested in learning Ax-SSRS report development ? Looking to improve your skills with Ax based SSRS report development ?
Here is a solution. Pre-order the Dynamics Ax 2012 Reporting cookbook I have authored.
Dynamics Ax Reporting Cookbook
This book will
-
Take you in to the depths of SSRS and build reports with confidence,
-
Make sure you utilize every feature possible with SSRS
-
Detailed examples on using controls like List, Chart, Gauges, Maps
-
Offer nice tips to enhance your development ability
-
Interesting methods to speed up report testing and development
-
Introduce you to tools that can help analyze report usage
-
Helps you stop hitting google for every problem with SSRS 🙂
and much more.
Pre-order today for a discounted price.
The book is expected in September 2013.
Related articles
- 5 ways to import your Data in Microsoft Dynamics AX 2012 (teamaxapta.wordpress.com)
- SSRS – an Introduction (sharmilli.wordpress.com)
- SQL Server Reporting Services Tips and Tricks to Improve the End-User Experience (dattatreysindol.com)