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)
Register vars in onFetch
Ingo
Hi,
I'm trying to set some GlobalVars in the onFetch method for a jdbc-ds, like the following:
var item = row["RNK"];
var value = row["ITEM"];
reportContext.setPersistentGlobalVariable( item, value);
Then, I use this DS for a chart and change the y-axis-label with the value which is registered for this item, like:
if (axis.getType() == AxisType.LINEAR_LITERAL){
var value = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable(label.getCaption().getValue());
label.getCaption().setValue("..."+value.substring(13,18)+"...");
}
So, far everything works fine. But the bad thing is, that I'm now unable to select the data for the chart again (using the Report Designer):
Exception: ReportContext method [setPersistentGlobalVariable] can only be used in Runtime!
Unfortunatly, I don't display the contents for this ds in a table before, so I could not use the onCreate for the table neither.
Any solution? Or how can it be done in a better way?
Thanks,
Ingo
Find more posts tagged with
Comments
mwilliams
Hi Ingo,
I set up something similar to what you're talking about and experienced the same problem. I couldn't access the dataSet unless I commented out the PersistentGlobalVariable lines in my script. It could be a bug. With your application, are you not able to create the table and just hide it, so you can create the global variables there?
Regards,
Michael
adamzg
You can resolve this problem using a try / catch block...<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var test= null;
var isRuntime = true;
try {
test = reportContext.getGlobalVariable("myGlobalVar");
} catch (error) {
isRuntime = false;
}
</pre>
Then you can either use test, or run some conditional code if you know you're in the runtime engine (e.g. set values based on the global if you're in the runtime else set default value so you can see something in your report if you're not).