Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » checking date parameter and changing it to default
checking date parameter and changing it to default [message #753651] Fri, 28 October 2011 04:12 Go to next message
Eclipse User
Hi,
I'm using deployed WebViewerExample (3.7) and I want to check if the
date parameter has the specified value. The script:
if(params["from_date"].value == '3000-01-01')

doesn't work. What is the proper syntax?

Generally I want the date parameter to have default value if I don't
provide any. I'm running the report remotely from cron in xls format (so
I can't let the parameter dialog appear) and the default values for
from_date and end_date are calculated in Birt (start of the month and
yesterday). I tried to make a script which would allow to put the value
'default' into date parameters:

http://server/frameset?__report=sales.rptdesign&from_date=default&to_date=default&__format=xls

and then change it to default values in birt, but it doesn't allow me to
put strings into date parameters. So i decided to put the fictional
values like 3000-01-01 and convert this values to default ones.

reportContext.setParameterValue("from_date",
reportContext.getDesignHandle().getParameters().get("from_date").getDefaultValue());

Are some more elegant ways to do this?

Thanks,
Rafal
Re: checking date parameter and changing it to default [message #753773 is a reply to message #753651] Fri, 28 October 2011 12:58 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

If you do not make the parameter required it will automatically use the
default date you set. You can either just add it or if you want to use
an expression do something like:

var myDate = new Date();
myDate.setHours(11);
myDate.setMinutes(59);
myDate.setSeconds(59);
myDate.setFullYear(2010,0,14);
myDate;

Jason


On 10/28/2011 4:12 AM, Rafal Wojtowicz wrote:
> Hi,
> I'm using deployed WebViewerExample (3.7) and I want to check if the
> date parameter has the specified value. The script:
> if(params["from_date"].value == '3000-01-01')
>
> doesn't work. What is the proper syntax?
>
> Generally I want the date parameter to have default value if I don't
> provide any. I'm running the report remotely from cron in xls format (so
> I can't let the parameter dialog appear) and the default values for
> from_date and end_date are calculated in Birt (start of the month and
> yesterday). I tried to make a script which would allow to put the value
> 'default' into date parameters:
>
> http://server/frameset?__report=sales.rptdesign&from_date=default&to_date=default&__format=xls
>
>
> and then change it to default values in birt, but it doesn't allow me to
> put strings into date parameters. So i decided to put the fictional
> values like 3000-01-01 and convert this values to default ones.
>
> reportContext.setParameterValue("from_date",
> reportContext.getDesignHandle().getParameters().get("from_date").getDefaultValue());
>
>
> Are some more elegant ways to do this?
>
> Thanks,
> Rafal
Previous Topic:complicated print form
Next Topic:Native excel file
Goto Forum:
  


Current Time: Mon Jul 28 20:39:17 EDT 2014

Powered by FUDForum. Page generated in 0.02413 seconds