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)
How to set script context for data engine from script?
rsenden
<p>Hi all,</p>
<p> </p>
<p>I have developed some JavaScript classes to allow dynamic execution of data sets from within report scripts; see attached. This utility can either execute existing data sets, or execute arbitrary SQL by defining a temporary data set.</p>
<p> </p>
<p>So far this works like a charm, except when executing an existing data set that references any JavaScript functions or objects defined elsewhere in the report. For example, executing a data set that references report parameters as the default value for data set parameters, or a data set that calls JavaScript methods defined in external JavaScript files defined via report resources will fail because the parameters and other JavaScript objects are unavailable while executing the query definition.</p>
<p> </p>
<p>I guess in order for this to work, I need to pass the current JavaScript scope to the DataSessionContext constructor and/or prepare() method call, for example:</p>
<div>
<pre class="_prettyXprint">
var myconfig = reportContext.getReportRunnable().getReportEngine().getConfig();
var dataEngine = DataRequestSession.newSession(myconfig, new DataSessionContext(3, moduleHandle, topScope));
...
dataEngine.prepare( queryDefinition ).execute(queryScope); </pre>
</div>
<p> </p>
<p>So, I have the following questions:</p>
<ul><li>How do I get a reference to the Scriptable object for the currently running report?</li>
<li>Should I pass this object to the DataSessionContext constructor, execute() method or both?</li>
<li>Should I also pass the moduleHandle (and how do I get it), or can I pass null?</li>
</ul><p> </p>
<p>Thanks,</p>
<p> </p>
<p>Ruud</p>
Find more posts tagged with
Comments
There are no comments yet