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

$P{LoggedInUsername} works in a text box, not in the query.


mike.atkinson
Go to solution Solved by mike.atkinson,

Recommended Posts

I have a simple report which displays an total for month to date.

The footer of this report does display the user who is logged into JasperReports Server Pro.

This was completed by creating the parameter:

LoggedInUsername - Class = java.lang.String - Is For Prompting = False

 

SELECT count FROM table WHERE CreationDate > First_Day (Current_Date) AND table.user = '$P!{LoggedInUsername}'

If I hard code a value the report works fine.

If I attempt to use the paramter LoggedInUsername, it fails.

I have tried surrounding the parameter in single quotes .... and without the single quotes.

I have tried placing an exclamation mark between the P and open Brace .... and without the exclamation mark.

I have tried with all the variations of the above I can think of.

the cvurrent and most common error is   : Query parameter not foundd: LoggedInUsername ----net.sf.jasperreports.engine.design.JRDesignQuery@xxxxxxx

In the Public - Library - Input Control resource editor I have defined LoggedInUsername as an Input Control || Single Value || Local Resource = DataType = Text

 

Any suggestions are appreciated.

 

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

It's a curious phenomenon.
For debugging purposes, why don't you try placing a temporary text field?
For the text feed expression, specify $P{LoggedInUsername}.
Check to see if the 'value displayed' matches the 'value you specified in the fixed value'.
You may be able to find 'differences in uppercase and lowercase letters' or 'differences with and without extra spaces'.

I tried with the following SQL and it worked as expected.
The database I am using is MySQL, so the syntax is a little different.
 

select * from tablewhere CreationDate > date_format(curdate(), "%Y-%m-01")AND table.user =  $P{LoggedInUsername}

- test data

w20211201_t13_data.png.dff8eee62874a02371cef0c914757783.png

- Report Design

w20211201_rep_design.png.1f546ec042b56b1769b0a289c4a70c0b.png

 

- Report Display Results

w20211201_rep_view_0.png.eb3ead1389f97e352d6317c71690cec3.png

 

 

 

 

Link to comment
Share on other sites

yama818 ... thanks.

I have a text box on the report, and it does populate with my username. Case sensitivity on the parameter is important.

The challenge continues to be the query. My current status is that I have gotten past the error, but it still doesn't seem to be populating the correct result.

To get past the errors, I had to do two things:

  • A - Create the Parameter in the Main Body of the report.
  • B - And the add that parameter to the Table Dataset.

This eliminates the error when previewing. But it still is not populating the correct answer.

So, I continue to work on it. Again ... Thanks,

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...