Wednesday, October 5, 2011

SSRS Embedded VB Script

In my case I am needing a UserName function to bind to the parameters. The goal is to limit the location parameters based on the UserName. So I added a UserName vb function in the embedded code section of the report. 

Go to Report > Properties > Code

Add the following function:
Public Function UserName()
          Return Report.User!UserID
          Return "System"
      End Try
End Function

Now go to Parameters and set default value of UserName to: =code.UserName()

This will bind your userName function to the actual UserName parameter.

Good luck