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)
Can not access PGV set in onFetch of dataset, later in onPrepare of TextItem.
dhanuap2011
<p>This is a simple example where I am setting PGV with onFetch method of dataset.</p>
<p> reportContext.setPersistentGlobalVariable("myvar2","Hi123");</p>
<p> </p>
<p>Then trying to access it in onPrepare method of TextItem.</p>
<p> reportContext.getPersistentGlobalVariable("myvar2");</p>
<p> </p>
<p>I have made sure that there is element in report (above TextItem), which is tied to the dataset so that onFetch method is called.</p>
<p> </p>
<p>However it returns null in textItem. What is wrong here.</p>
<p> </p>
<p>Attached rptdesign.</p>
Find more posts tagged with
Comments
dhanuap2011
<div>In dataset, with onFetch method I am setting PGV.</div>
<div> reportContext.setPersistentGlobalVariable("myvar2","Hi123");</div>
<div> </div>
<div>In TextItem, with onPrepare method I am accessing PGV</div>
<div> reportContext.getPersistentGlobalVariable("myvar2")</div>
<div> </div>
<div>However it returns null.</div>
<div> </div>
<div>I have made sure that, there is an element in report (above TextItem) which is tied to dataset so that onFetch method is run.</div>
<div> </div>
<div>what is wrong here. PFA</div>
<div> </div>
<div>
micajblock
<p>That is because the onPrepare method gets called before the onFetch. This video might help:</p>
<p> </p>
<p>
https://www.youtube.com/watch?v=FQ9VjByPNWM</p>
Matthew L.
<p>In your example, you could set the text of the text element in the text's onRender method using the following command:</p>
<pre class="_prettyXprint _lang-js">
var str = reportContext.getPersistentGlobalVariable("myvar2");
this.text = str;
</pre>
<p>The .setContent() method seems to only work in beforeFactory (or earlier) however a data set's onFetch is during factory which is too late for .setContent() and beforeFactory is too early for the variable set during onFetch.</p>
<p> </p>
<p>You could query the data set early to get its value using API code (<a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/35930-running-a-query-in-the-initalize/?p=133369'>http://developer.actuate.com/community/forum/index.php?/topic/35930-running-a-query-in-the-initalize/?p=133369</a>)
or set the value later on such as the onRender method example above.</p>
dhanuap2011
<p>Thanks. It worked.</p>