Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How Do I use global variables?
megabri
<p>I was wondering how to use global variables in BIRT? I'm currently using parameters as global variables but it's giving me issues when I import my report into Maximo. Can someone tell me step by step how to set up and use global variables? I'll need to use the same global variable across multiple grids/dataSets/tables. Thanks!</p>
Find more posts tagged with
Comments
kclark
<p>Hi mega! To use a "global variable" you'll need to set what we call a GlobalPersistentVariable. You can set these anywhere you have access to reportContext:</p>
<pre class="_prettyXprint _lang-">
reportContext.setPersistentGlobalVariable("variableName", value);
</pre>
<p>And to access the same variable you'd use</p>
<pre class="_prettyXprint _lang-">
var temp = reportContext.getPersistentGlobalVariable("variableName");
</pre>
<p>I'll write an example if you need one, just let me know!
</p>
megabri
<p>I can't use the Variable section that i found in the Outline section? I have about 20 grids on my report that need to check a value. I wanted to save the value of a field i get in a query to this global variable then use it through out the 20 grids. So currently my fetch looks like this....</p>
<p> </p>
<div>if (!maximoDataSet.fetch())</div>
<div>return (false);</div>
<div> </div>
<div>row["alnvalue"] = maximoDataSet.getString("alnvalue");</div>
<div> </div>
<div>params["insptype"].value = row["alnvalue"];</div>
<div>return (true);</div>
<div> </div>
<div>I want that insptype to be a global variable rather than a parameter. Any thoughts?</div>
kclark
<p>I'm not too familiar with maximo, let me look into this a little more and let you know what I find, in the meantime maybe someone else knows the answer?</p>
kalpana5
<blockquote class="ipsBlockquote" data-author="kclark" data-cid="129283" data-time="1404917629">
<div>
<p>I'm not too familiar with maximo, let me look into this a little more and let you know what I find, in the meantime maybe someone else knows the answer?</p>
</div>
</blockquote>
<p>Hi,</p>
<p> </p>
<p>Hopefully I have followed the forum correctly, I am not very much familiar with the code .</p>
<p> </p>
<p>In the fetch method as soon as you retrieve alnvalue</p>
<p> </p>
<p>please add the below code</p>
<p>reportContext.setPersistentGlobalVariable(var,row["alnvalue"]);</p>
<p> </p>
<p>Also make sure to declare the variable var.</p>
<p> </p>
<p> </p>
<p>On the Report Layout, you can compare the value or retrieve the value as</p>
<p> </p>
<p>reportContext.getPersistentGlobalVariable(var).</p>
<p> </p>
<p>Thanks, hope this will help.</p>