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)
Dataset results to be used in report script
nikodem38
Hi,
I want to use the result of a dataset to create a grid
I put the results of the dataset in an array and pass it to a global variable which is initialized in the 'initialize' script tab of the report:
mylist=new Array();
reportContext.setGlobalVariable("alist",mylist);
Now I need to use this global variable in order to create a grid, values of the variable being part of the grid cells.
For that, in the 'beforeFactory' script tab of the report, I wrote:
dslist=reportContext.getGlobalVariable('alist');
But dslist is empty
Please help
Find more posts tagged with
Comments
kclark
Why don't you just make a table on your report and drag the data you need from the dataset to it? Is there something specific you are trying to do that you need scripting for?
nikodem38
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="110153" data-time="1349374819" data-date="04 October 2012 - 11:20 AM"><p>
Why don't you just make a table on your report and drag the data you need from the dataset to it? Is there something specific you are trying to do that you need scripting for?<br /></p></blockquote>
<br />
The grid I want to create is a calendar with months as columns and days as rows.<br />
the result of the dataset gives a column of names and a column of dates.<br />
I want to put these names in the correct grid cells depending on the dates values.<br />
<br />
In the report script tab, I try to execute the query of the dataset to get the results.<br />
<br />
here is the code for executing the dataset:<br />
var myconfig=reportContext.getReportRunnable().getReportEngine().getConfig();<br />
var des=DataRequestSession.newSession(myconfig,new DataSessionContext(1)); var dsrc=reportContext.getDesignHandle().findDataSource("MPW3DB");<br />
var dset=reportContext.getDesignHandle().findDataSet("TEST");<br />
des.defineDataSource(des.getModelAdaptor().adaptDataSource(dsrc));<br />
des.defineDataSet(des.getModelAdaptor().adaptDataSet(dset));<br />
<br />
queryDefinition=new QueryDefinition();<br />
queryDefinition.setDataSetName("TEST");<br />
<br />
var pq=des.prepare(queryDefinition);<br />
var qr=pq.execute(null);<br />
var ri=qr.getResultIterator();<br />
var rsmd=ri.getResultMetaData();<br />
var countrow=-1;<br />
var listmp=new Array();<br />
while (ri.next()) {<br />
countrow++;<br />
listmp[countrow]=ri.getValue(rsmd.getColumnName(1));<br />
}<br />
ri.close();<br />
qr.close();<br />
des.shutdown();<br />
<br />
<br />
When I execute it, I get the following error message:<br />
"Wrapped org.eclipse.birt.data.engine.core.DataException: In generation or presentation, report archive can not be null."