Jump to content
We've recently updated our Privacy Statement, available here ×

Capture the name of the person logged onto Jasper


deepskansal
Go to solution Solved by swood,

Recommended Posts

Hi Everyone,

I have a requirement to display the name of the user logged onto JasperServer on all the reports he/she access within repository.
As per a sample report names 'Sales By Month Report' available in Repository on JasperServer Pro 3.1 the same could be achieved by creating a parameter with parameter class as: <com.jaspersoft.jasperserver.api.metadata.user.domain.User>.
However I am not able to make it work.
Could anyone please guide me how to achieve this?

Thanks,
Deepak

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

Have a look at the JRXML for the Sales By Month report.

 

In your report, create a parameter:

 

    <parameter name="LoggedInUser" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User"/>
 

 

This will automatically be populated when you run the report in JasperServer.

 

In the report, you can refer to this parameter, like:

 

<textFieldExpression class="java.lang.String"><![CDATA[$P{LoggedInUser}.getFullName()]]></textFieldExpression>

 

or

 

<textFieldExpression class="java.lang.String"><![CDATA[$P{LoggedInUser}.getUsername()]]></textFieldExpression>

 

 

Sherman

Jaspersoft

 

Link to comment
Share on other sites

  • 4 years later...

Hi Swood,

 

as per your suggestion, i have created the sample. please find below jrxml file. i am getting empty report only. i not getting loggedinUserName. please advice me

 

<?xml version="1.0" encoding="UTF-8"?>

$P{LoggedInUser}.getUsername()

$P{Username}

Test

Test

is there anything i am missing. still my report is empty.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...