Jump to content

BIRT Developer Center Download


Photo
- - - - -

Using JSAPI to read data from BIRT report


  • Please log in to reply
5 replies to this topic

#1 sandhyany

sandhyany

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 09 December 2016 - 12:57 PM

I have a report with 3 parameters. I need to create a script that reads data from this report and stores it in database. The script be scheduled to run as a Windows job. I get no errors but the code does not reach dispalyData(rs)

 

function getResultset( )
{
actuate.authenticate
 ("http://xxxxx:8700/iportal" ,  null, "username", "password", null, getResultset1, errorHandler);
}
 
function getResultset1( )
{
file = "/xxxxx/xxxxxx/xxxxx/xxxxxxxxxxxx.rptdocument";
var requestOpts = new actuate.RequestOptions( );
requestOpts.setRepositoryType(actuate.RequestOptions.REPOSITORY_ENCYCLOPEDIA );
requestOpts.setCustomParameters({PIYearParam: "2016",PIMonthParam: "7",DayType: "1"});
var dataservice = new actuate.DataService();
dataservice.setService("http://xxxxx:8700/iportal",requestOpts);
var request = new actuate.data.Request("bookmarkName",1,100);
dataservice.downloadResultSet(file, request, displayData, errorHandler);
alert("At the end.");
}
 
function displayData(rs)
{
alert("In Display Data");
var columns = rs.getColumnNames( );
while (rs.next( )){
for (var i = 0; i < columns.length; i++){
document.writeln(rs.getValue(columns[i]));
}
}
}
 
function errorHandler(exception)
{
alert("Your application encountered an exception: \n" + exception.getMessage());
}


#2 sandhyany

sandhyany

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 09 December 2016 - 02:18 PM

I think  I have used .setCustomParameters incorrectly and looks like it may not be possible to pass parameters when downloading resultset from a report.



#3 sandhyany

sandhyany

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 12 December 2016 - 09:47 AM

I was able to download the report result set using the viewer object (viewer.downloadResultSet()). Would like to use a dataservice object instead. But don't to know how to pass the parameters as with viewer (viewer.setParameters()).



#4 Clement Wong

Clement Wong

    Senior Member

  • BIRT Experts
  • 1129 posts

Posted 12 December 2016 - 04:51 PM

You won't be able to pass parameters into a .RPTDOCUMENT because the report has already been generated with the parameters previously specified to generate the report. 

 

What's the ultimate goal other than "I need to create a script that reads data from this report and stores it in database."

 

You can add code into your report design that writes to the database.

 

If you have specific parameters, you'll first need to run a .RPTDESIGN and then with the .RPTDOCUMENT extract the data.

 

The REST API also provides this service and allows you to extract data from a materialized Data Object (.DATA) via /dataobject/dataExtraction.


Clement Wong
Principal Analytics Architect

OpenText Corporation
http://www.actuate.com | http://www.opentext.com


#5 sandhyany

sandhyany

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 13 December 2016 - 12:27 PM

Thanks Clement for your help.

 

You won't be able to pass parameters into a .RPTDOCUMENT because the report has already been generated with the parameters previously specified to generate the report

--> This makes it clear why I cannot use dataservice object to extract data from a report that has parameters and all do not have default values.

 

You can add code into your report design that writes to the database

-->I don't have access to or control over report design

 

My ultimate goal:

I have to create something in .net that reads data from a parameterised BIRT report and writes it to an Oracle table. This something should be scheduled to run automatically few times a month. 



#6 Clement Wong

Clement Wong

    Senior Member

  • BIRT Experts
  • 1129 posts

Posted 15 December 2016 - 06:54 PM

One option:

In the iHub, you can schedule the .RPTDESIGN to generate the .RPTDOCUMENT.

 

Then, you can schedule your .NET app to read from the the .RPTDOCUMENT to write to the Oracle table.

 

 

Another option as suggested previously.

Add logic into your .RPTDESIGN to write to the Oracle table.  In the iHub, schedule the .RPTDESIGN as needed.


Clement Wong
Principal Analytics Architect

OpenText Corporation
http://www.actuate.com | http://www.opentext.com