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)
DataService Example
stoddard
Does anyone have a working dataservice example? I seem to be having some trouble getting the callback for downloadResultSet to work.
Thanks
Find more posts tagged with
Comments
rmurphy
I'm assuming you are wanting to perform a data extract from a report using the JSAPI, correct?<br />
<br />
If so, the data extract is peformed against a rptdocument file and not a rptdesign. I believe the documentation incorrectly says you can use a rptdesign.<br />
<br />
Here is some sample code for extracting data using the data service.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function init(){
actuate.load("dataservice");
actuate.initialize( "http://server:8900/iportal/", null, "administrator", "", createDataService );
}
function displayData(rs){
var columns = rs.getColumnNames();
while (rs.next()){
for (var i = 0; i < columns.length; i++){
window.alert(rs.getValue(columns[i]));
}
}
}
callBackError=function(exception){ window.alert('ERROR: ' + exception); };
function createDataService(){
dataService = new actuate.DataService("http://server:8900/iportal");
var request = new actuate.data.Request("Top 5 Customers");
dataService.downloadResultSet("/Public/BIRTReports/MyReport.rptdocument", request, displayData, callBackError );
}
</pre>
<br />
<br />
Hope this helps<br />
Rob
pooh
Helo,<br />
<br />
<br />
When I try to load actuate.load("dataservice"), the code hangs there. it doesn't go beyond it.<br />
<br />
This is my script : <br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function dataServiceInit()
{
actuate.load("dataservice");
actuate.initialize( "http://localhost:8900/iportal/", null, "administrator", "", createDataService );
}
function displayData(rs)
{
var columns = rs.getColumnNames();
while (rs.next()){
for (var i = 0; i < columns.length; i++){
window.alert(rs.getValue(columns[i]));
}
}
}
callBackError=function(exception){ window.alert('ERROR: ' + exception); };
function createDataService()
{
dataService = new actuate.DataService("http://localhost:8900/iportal/" );
var request = new actuate.data.Request( "mytable" );
request.setStartRow( 1 );
request.setMaxRows( 50 );
dataService.downloadResultSet( "/Home/administrator/ci_reports/table.report.rptdesign", request, displayData(request) );
}
function selectCheckBox()
{
var e = document.frm.elements.length;
var cnt=0;
for(cnt=0;cnt<e;cnt++)
{
if(document.frm.elements[cnt].name=="cbTable")
{
if(document.frm.elements[cnt].checked) {
alert(document.frm.elements[cnt].value)
}
}
}
}
function init()
{
// initialize the birt library, then call createViewer as a callback.
actuate.load("viewer");
actuate.initialize( "http://localhost:8900/iportal/", null, null, "", createViewer );
}
/**
* Function which creates the viewer.
* It is called as a callback to BirtLib.initialize().
*/
function createViewer()
{
<?php global $sel_subject; ?>
// instantiate a viewer object, by specifying the report file to be used and the HTML container to use.
myViewer = new actuate.Viewer( "myDivContainer" );
var uioptions = new actuate.viewer.UIOptions();
uioptions.enableToolBar(false);
uioptions.enableColumnResize(true);
myViewer.setUIOptions(uioptions);
// myViewer.setReportName("/Home/administrator/ci_reports/complete.report.rptdesign" );
myViewer.setReportName("/Home/administrator/ci_reports/table.report.rptdesign" );
myViewer.setParameters({"industry":"<?php echo $sel_subject; ?>"});
myViewer.setSize(800,myViewer.getClientHeight());
// execute the viewer creation
myViewer.submit();
}
</pre>
drewdudek
I'm having this same issue.<br />
<br />
<strong class='bbc'>Does anyone have the answer yet?</strong><br />
<br />
I use <strong class='bbc'>actuate.load("dataservice")</strong> just like the example but it gives the javascript EXCEPTION<strong class='bbc'> Invalid module name "dataservice".<br />
</strong><br />
Thanks.<br />
<br />
Drew