Skip to main content



      Home
Home » Archived » BIRT » Set a global variable using report parameter(Which event must be handled in order to have the parameter already set?)
Set a global variable using report parameter [message #820661] Wed, 14 March 2012 08:03 Go to next message
Eclipse UserFriend
I want to read a report parameter and, basing on its value, create some derived variables to be put in the report context:

reportContext.setGlobalVariable("global_refdate", params["refdate"].value);


The final goal is to use these variables inside dynamic text elements, report header/footer, ...

The problem is that I can't understand where to put the script, because I don't know when the parameter is evaluated (and not null) during the report generation.

I've put it in many event handler scripts of the report element:

initialize
before factory
after factory

but the global variable is always null when I'm trying to use it with:

reportContext.getPersistentGlobalVariable("global_refdate");



Can someone help me, please?
Thanks in advance...
Re: Set a global variable using report parameter [message #820768 is a reply to message #820661] Wed, 14 March 2012 10:47 Go to previous messageGo to next message
Eclipse UserFriend
A friend suggested me the solution: I was not setting the variable as "Persistent".


WRONG --> reportContext.setGlobalVariable("global_refdate", params["refdate"].value);
CORRECT --> reportContext.setPersistentGlobalVariable("global_refdate", params["refdate"].value);


Now it seems working, by putting the script in the initialize event handler of report component.

Thanks anyway...
Re: Set a global variable using report parameter [message #821037 is a reply to message #820661] Wed, 14 March 2012 17:35 Go to previous messageGo to next message
Eclipse UserFriend
The beforeFactory is ideal. Are you setting global variable like:
setPersistentGlobalVariable or using setGlobalVariable?
the get must match.

Jason

On 3/14/2012 8:03 AM, ing omini wrote:
> I want to read a report parameter and, basing on its value, create some
> derived variables to be put in the report context:
>
> reportContext.setGlobalVariable("global_refdate", params["refdate"].value);
>
> The final goal is to use these variables inside dynamic text elements,
> report header/footer, ...
>
> The problem is that I can't understand where to put the script, because
> I don't know when the parameter is evaluated (and not null) during the
> report generation.
>
> I've put it in many event handler scripts of the report element:
>
> initialize
> before factory
> after factory
>
> but the global variable is always null when I'm trying to use it with:
>
> reportContext.getPersistentGlobalVariable("global_refdate");
>
>
> Can someone help me, please?
> Thanks in advance...
>
Re: Set a global variable using report parameter [message #831941 is a reply to message #821037] Thu, 29 March 2012 10:51 Go to previous message
Eclipse UserFriend
I will try with "beforeFactory"...
Thanks
Previous Topic:Data set expressions and design element expressions
Next Topic:Problems with hyperlinks on images/report designer
Goto Forum:
  


Current Time: Thu Jul 17 19:25:12 EDT 2025

Powered by FUDForum. Page generated in 0.07679 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top