I'm new to SSRS, so I apologize if this question is too simple:
I have a report which accepts a parameter called "Amount". I want to constrain valid inputs to currency values >= 0, and pop open an error message if the user enters improper values.
I don't want to validate inputs in my stored procedure and throw exceptions, because SSRS displays a very generic "Query execution failed for 'someTable'" message to users who access the report from another machine, and my business does not want to turn on the "Enable Remote Errors" flag.
How do I add input validation to report parameters and notify users of bad input?
Yes, I've googled around, but haven't had much luck. Thanks in advance :)
For a subroutine expecting named parameters, you would do this: validate( @_ , { foo => 1, bar => 1, baz => 0 } ); This says that the "foo" and "bar" parameters are mandatory and that the "baz" parameter is optional. The presence of any other parameters will cause an error.
Parameters are one of the built-in collections that you can include in an expression in a report. Because expressions are used to define values throughout a report definition, you can use parameters to control report appearance or to pass values to related subreports or reports that also use parameters.
You can pass report parameters to a report by including them in a report URL. These URL parameters are not prefixed because they are passed directly to the report processing engine.
Report parameters allow you to control the report's content, to connect related reports, or to use them as arguments in functions.
Okay, how about this?
All you have in SSRS, really, is the SQL query and expressions in report fields.
Perhaps you could add a big, red text box at the top of the report for your error message, and give it an expression like '=IIf(Parameters!Amount.Value < 0, "Error: Invalid Amount", "")'.
Then go to your table's "Hidden" property and give it the expression "=Parameters!Amount.Value < 0"
You could also add into your query's where clause and add "AND @Amount >= 0" so you aren't fetching from the database when there's an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With