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.
3 Answers:
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 TABLE WHERE CreationDate > date_format(curdate(), "%Y-%m-01") AND TABLE.user = $P{LoggedInUsername}
- test data
- Report Design
- Report Display Results
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,
Attachment | Size |
---|---|
![]() | 65.44 KB |