Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Sample report to access global variable
Ulf
Hey there,
can you tell me how to set a global variable and how i can access to a global variable ?
Birt Engine: 2.6.1
What I try to do?
I try to set an global variable which has an number. It can be 1 or 0.
And if this variable is 0, one of my grids should disappear(visibilty=true).
Best wishes
Ulf
Find more posts tagged with
Comments
mwilliams
Hi Ulf,
How is this global variable set? By a parameter? By data in your dataSet?
Ulf
if(row['__ronnum'] > 10)
{
var test = 1;
reportContext.setPersistentGlobalVariable("breakpage",test);
}
Thats what in my dataset script.
mwilliams
You'll have to set the value of the PGV to test.toString(). Then, when you recall it later in your script, you'll have to do:
temp = parseInt(reportContext.getPersistentGlobalVariable("breakpage"));
PGV's only store strings and objects.
Hope this helps.
Ulf
in my dataset i've got now:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var test= 0;
if(row['__ronnum'] > 47)
{
test.toString = 1;
reportContext.setPersistentGlobalVariable("breakpage",test);
}
</pre>
<br />
Is that right?<br />
<br />
Then i want to set an Expression to my grid (visibilty).<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if(breakpage == 1)
{
true;
}
</pre>
<br />
Can you correct me, if it's wrong !?<br />
<br />
Thanks a lot.
mwilliams
It'll need to be something like:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var test = 0;
if(row['__ronnum'] > 47){
test = 1;
reportContext.setPersistentGlobalVariable("breakpage",test.toString());
}
</pre>
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
temp = parseInt(reportContext.getPersistentGlobalVariable("breakpage"));
if (temp == 1){
true;
}
else{
false;
}
</pre>
Ulf
In my table i've got now in the "onPrepare" Script<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var test= 0;
if(row['__ronnum'] > 47)
{
umbruch = 1;
reportContext.setPersistentGlobalVariable("breakpage",test.toString());
}
</pre>
<br />
<br />
The if-clause doesen't work. Any ideas?
mwilliams
The data isn't avaialble in the onPrepare method. You'd have to do that in the onCreate method.