I am adding security to my reports to limit which records appear based on who is executing the report. I modified all of my stored procedures that are used in report Datasets to accept an @UserId parameter. Our application will pass that parameter to the reports. I am now adding the parameter to the .rdl files themselves. For most, this was easy. I just add a hidden parameter, map it in the Dataset parameters list, and everything works. But for a few, I get this error:
The Value expression for the query parameter '@UserId' contains an error. The expression references the parameter 'UserId', which does not exist in the Parameters collection. Letters in the names of parameters must use the correct case. (rsRuntimeErrorInExpression)
I am absolutely sure there is no case mismatch problem as the parameter name was copy and pasted everywhere it appears, it works fine in dozens of reports, and it matches even in the error message. What the problem reports seem to have in common is that they have multiple Datasets that need the parameter where at one Dataset is used to select a value for another report parameter.
For example, a report will display information about customers. It has a multi-select parameter for a list of customers. It is now filtered by the @UserId. The main Dataset stored procedure for the report takes both the @CustomerIdList and the @UserId (in case the proc will be called other than by the report).
Report Builder (or SSRS) seems to get confused by @UserId being needed for both Datasets (CustomerList and CustomerData), where CustomerDataalso also needs the result of CustomerList as a parameter. Although the error message says that @UserId isn't a parameter, it clearly is.
How can I work around this problem?