Reporting in Perspective ( Get Current User )

Hi guys, have a good days.

Currently, I’m doing the reporting in perspective which I will show the report in report viewer. In this case, I actually want to put the current user in the report module which I will get the current user that login in the session and put in the reports. May I know it is possible.

The best way I think of doing this is create a new parameters and get the current user in the parameters but when I do this it dint work. May I know anyone do this before.

Thanks in advance.

This is probably the correct answer. Please show us what you tried.

1 Like

Be sure to use Perspective’s authenticated user “session.auth.user.userName” instead of Vision’s “system.security.getUsername”.

What I had tried was I just write the code of userName = session.props.auth.user.userName

That looks correct, but I suspect no user is logged in. Does your project require authentication? If not, you might want to look into at least requiring a user log in before accessing the View which contains the Report.

Hi @cmallonee, Image attached is the code that I write and the error message that prompt up. May I know what solution I should do to solve these problems.

2.

Thanks in advance.

Ah, the Report itself has no concept of a session. You will be unable to supply a default value which is a username. Perspective should supply the username as a param of the property. I have verified this does indeed work.

The report should be set up just like you have it, but supply a placeholder string in the expression. In my example I supply a value of “Fake”. My username variable is just userName, but the name does not matter. Your Perspective Report component should supply a case-specific param, and you should bind that param to the session property we mentioned previously.

Report Configuration:

Screen Shot 2021-08-11 at 7.16.30 AM

Perspective component configuration (you can see in the background that the report is using “admin” as the username because the admin user is logged into the Designer):

3 Likes