Here is a work around using a custom code function.
If you have really complex tasks - or ones like our problem - then VB code can be embedded in your report server report.
- In Design view, right-click the design surface outside the border of the report and click Report Properties.
- Click Code.
- In Custom code, type the code.
- Public Function UserName()
Try
Return Report.User!UserID
Catch
Return "System"
End Try
End Function
Now we need to make the user name available as a parameter in the report so we can use it in our underlying SQL.
- Click on the Report Menu -> Parameters
- Add a new parameter
- In the default values use a non queried value of =Code.UserName() to call the custom code we entered above.
- This particular parameter is needed to determine the list of Market parameters used in this report. It needs to be moved (using up and down arrows) above any parameters dependant on it - in this case Mkt.
The @UserName parameter is now available for us to build our SQL in the data section of the report.
No comments:
Post a Comment