Setting default parameter values
One of the most commonly asked questions over the past few years in the newsgroups have been "How can I set a date parameter to default to the current date?"
Before BIRT 2.5, this was not an easy task to accomplish. However, new to BIRT 2.5 is the ability to set a date parameter's default value via script. Let's go about it:
1. Create a new report called
defaultParameterValueReport.rptdesign
.2. Create the Classic Cars Sample Database Data Source.
3. Create a dataset called
dsOrderRange
, with the help of following query:select * from CLASSICMODELS.ORDERS where CLASSICMODELS.ORDERS.ORDERDATE between ? and ?
4. Link the two dataset parameters to report parameters called
prmStartDate
andprmEndDate
. Make sure the two dateset parameters and two report parameters are of typeDate
.5. Open the editor for
prmStartDate
. In the drop-down box next to Default value, select Javascript Syntax and continue.6. Use the following script in the expression builder. Don't worry...