Filter report data based on user accessing report?

  • Guys,

    I'm creating a report which is going to list the tasks a particular user has. Rather than having a drop down list and the user select their name to display a report I'd like the report to 'detect' the user who's trying to access it and then pass this into the report.

    Is this possible? If so how would I go about doing it?

    Say for instance it was a dead simple query of 'select * from tasks where task_owner = X'

    At the moment I'd be producing a dataset of all tasks and then a data set of users, I'd then add a paramater which mapped X to a username.

    We don't have AD tied in with the database which stores this data so I guess I'll need a mapping between AD username and database username. Would the AD usernames be in the format of domain\username or just username?

    Hopefully I've explained myself okay, any help much appreciated 🙂

  • Hi Rob,

    Perhaps the built-in field UserID is the way to go; you should first add it at your report header to find out the field format, mine is: DOMAIN\USER, e.g. jupiter\sandovaa; once you know its formatting structure you can add it to your data source, your query is likely to become something like this:

    select * from tasks where task_owner = @[Owner]

    Your last hurdle is working out how the task_owner was written to the tasks table and with the UserID format.

    Cheers,

    Hope this helps,
    Rock from VbCity

  • That's really helpful, I wasn't aware of that built in field, thanks 😀

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply