Link to home
Start Free TrialLog in
Avatar of Karl_mark
Karl_mark

asked on

SSRS Pass UserId!UserId as Parameter to Data Set

Evening All! The following is on SSRS 2008.
I have a report set up which currently works by pulling the GUID of a User from our HR application and passes this as a parameter to an SSRS Report. It all works well and the report filters correctly.
However, it is obviously better to not pass the GUID as a parameter (even though the chances of a user figuring out someone else's GUID is minimal) and also using this method requires using a new window in the launching app to pull through the value; pulling the UserId in the report would enable me to place the report link on the main dashboard.

I've read around on Google and clearly the solution is to pass UserId!UserId as the parameter to  the Data sets. The data sets are Stored Procedures which will accept the UserId as a parameter. I've added a Parameter to the report called @UserId and set the default value as =UserId!UserId. The parameter in the data set is set as @UserId. I can't see anything wrong there!

At this point it's worth mentioning that the UserId itself is actually the person's employee number; we have custom authentication so there are no issues with domain names etc. getting in the way. I have tested this by running a report without the paramter but having UserId displayed in a text box and it returns the expected value.

The problem is that when I call the report from our web application I see the following error:

Microsoft.ReportingServices.Diagnostics.Utilities.UnknownReportParameterException: An attempt was made to set a report parameter 'UserID' that is not defined in this report.;

I'm not sure why I am seeing this error. The parameter in the stored procedures is called @GlobalID, but surely that can't be the cause can it? (I can't currently change it anyway as the data source is a database snapshot and for some reason the snapshot update job doesn't seem to be working - have to wait until the dba comes in tomorrow). Is there any other reason why I would get this message?
ASKER CERTIFIED SOLUTION
Avatar of sachiek
sachiek
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Karl_mark
Karl_mark

ASKER

Thanks Sachiek. It is now loading (or trying) to load the report at least!
The problem I'm having is that it doesn't seem to be applying the parameter (if I'm understanding the error correctly). I'm getting an error loading a dataset because of a "divide by zero error".
So, it is accepting UserID as a parameter (it would seem), but not generating any results as this is the same error I would get on the report server if I put in a non-existent UserID.
Is there any way of tracing what parameters are being applied to a report at runtime? The stack trace only tells me the data set name and the error message.
The parameter is now being accepted....