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)
using get/setPersistentGlobalVariable in scripts
gib65
<p>Hello,</p><p> </p><p>I have a question on how the functions getPersistentGlobalVariable(...) and setPersistentGlobalVariable(...) work in the scripts.</p><p> </p><p>So I have a script for the beforeOpen event in my dataset. It looks like this:</p><p> </p><p>fieldKey = "0";</p><p>reportContext.setPersistentGlobalVariable("fieldKey",fieldKey);</p><p> </p><p>Then I have a script for the onCreate event for one of my controls. It looks like this:</p><p> </p><p>importPackage( Packages.javax.swing );</p><p> </p><p>fieldKey = reportContext.getPersistentGlobalVariable("fieldKey");</p><p> </p><p><strong class='bbc'>if</strong> (fieldKey != <strong class='bbc'>null</strong>)</p><p>{</p><p>print(fieldKey);</p><p>}</p><p><strong class='bbc'>else</strong></p><p>{</p><p>print("fieldKey is null");</p><p>}</p><p> </p><p><strong class='bbc'>function</strong> print(message)</p><p>{</p><p>frame = <strong class='bbc'>new</strong> JFrame( message ); </p><p>frame.setBounds( 310, 220, 300, 20 ); </p><p>frame.show( ); </p><p>}</p><p> </p><p>The JFrame message that gets printed out is always "fieldKey is null".</p><p> </p><p>Why is fieldKey null if I set it with setPersistentGlobalVariable(...) in the dataset's beforeOpen event handler and then tried to retrieve it with getPersistentGlobalVariable(...) in the control's onCreate event handler?</p><p> </p><p> </p><p> </p>
Find more posts tagged with
Comments
CBR
<p>Can you provide a sample report?</p><p>You have to be aware of the fact that the beforeOpen is only called if the dataset is really needed to generate the report. To be more concrete it is called the time the corresponding element (table or list) is getting created.</p>