mike.atkinson Posted November 26, 2021 Posted November 26, 2021 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@xxxxxxxIn 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.
yama818 Posted November 30, 2021 Posted November 30, 2021 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- Report Design - Report Display Results
mike.atkinson Posted December 1, 2021 Author Posted December 1, 2021 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,
Solution mike.atkinson Posted December 1, 2021 Author Solution Posted December 1, 2021 I got it.Create a Parameter in the Main DatasetCreate a Parameter in the Table SubDatasetLink the two parameters together in the Table Dataset Properties.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now