viking79 Posted January 6, 2012 Share Posted January 6, 2012 Hello,I am trying to get the report I'm working on to prompt the user for a date range and only pull the items that fall within the range. This is all based off the po.datecreated field.Any help is greatly appreciated,Thanks Link to comment Share on other sites More sharing options...
svenn Posted January 6, 2012 Share Posted January 6, 2012 The only way to do that is to use some sort of front end to allow the user to select this. If you are using JasperServer I beleive it allows you to create controls to do this. If you use your own front end you will need to create a GUI that collects your values them kicks off the report. Link to comment Share on other sites More sharing options...
viking79 Posted January 6, 2012 Author Share Posted January 6, 2012 So you can't do this a parameter in ireport? Post Edited by viking79 at 01/06/2012 17:30 Link to comment Share on other sites More sharing options...
sefas Posted January 9, 2012 Share Posted January 9, 2012 If you create a report parameter and tick "use as a prompt" it should prompt you Link to comment Share on other sites More sharing options...
svenn Posted January 9, 2012 Share Posted January 9, 2012 Yes but unless things have changed that functionality only exist to test your report in iReport. It does not get activated when you run the report outside of the tool. Link to comment Share on other sites More sharing options...
cbarlow3 Posted January 12, 2012 Share Posted January 12, 2012 Svenn is correct--it's really a two-part question. The iReport of the answer is that you need to create parameters for the values you plan to input and use those parameters in your query...e.g.: SELECT po.id, po,description, po.datecreated FROM purchase_order as po WHERE po.date_created BETWEEN $P{StartDate} AND $P{EndDate}While testing in the preview mode of iReport, this is in fact enough to make it prompt you for the two dates.The second part of the answer depends on how your end user runs the report. Are you using JasperReports Server or do you have a Java program that is running your report just using JasperReport Library, or...?If your end user is using JasperReports Server, then you need to:1. Deploy your report to the repository in JasperServer2. Add input controls for each parameter that you want to prompt for3. Change the property of the report so that it always prompts (this isn't actually necessary--you could have the report automatically run once with the default values and then rely on the user to click on the oh-so-subtle (at least in Version 3.7) "Report options" icon to enter new values. But in most cases, I find it's better to always prompt first.Each of these three steps is relatively easy if you have the repository navigator plug-in and are used to finding your way around the repository. I've even defined standard input controls called StartDate and EndDate in the public folder of the repository so I can just link to them instead of creating new, local input controls each time. If you have problems with the input controls, you'll probably want to post on the JasperReports Server forum rather than iReport.If your end user is running some application you've written that in turn runs the report through JasperReports Library, then you will of course have to do your own prompting. How you pass that value along to the report depends on what you're doing, but if it's a Java application, you probably use:HashMap jasperParameter = new HashMap();jasperParameter.put("StartDate", startDate);JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, connection);You can then also use the various exoprters to create PDF, etc. If you have questions about THAT process, you'll probably want to post on the JasperReports Library forum.Carl Link to comment Share on other sites More sharing options...
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