Using JSAPI to read data from BIRT report

sandhyany
edited February 11, 2022 in Analytics #1
<p>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)</p>
<p> </p>
<div>function getResultset( )</div>
<div>{</div>
<div>actuate.authenticate</div>
<div> ("<a class="bbc_url" href="http://xxxxx:8700/iportal",null,"username","password&quot;&gt;http://xxxxx:8700/iportal&quot; ,</a>  null, "username", "password", null, getResultset1, errorHandler);</div>
<div>}</div>
<div> </div>
<div>function getResultset1( )</div>
<div>{</div>
<div>file = "/xxxxx/xxxxxx/xxxxx/xxxxxxxxxxxx.rptdocument";</div>
<div>var requestOpts = new actuate.RequestOptions( );</div>
<div>requestOpts.setRepositoryType(actuate.RequestOptions.REPOSITORY_ENCYCLOPEDIA );</div>
<div>requestOpts.setCustomParameters({PIYearParam: "2016",PIMonthParam: "7",DayType: "1"});</div>
<div>var dataservice = new actuate.DataService();</div>
<div>dataservice.setService("<a class="bbc_url" href="http://xxxxx:8700/iportal",requestOpts&quot;&gt;http://xxxxx:8700/iportal&quot;,requestOpts&lt;/a&gt;);&lt;span&gt; </span></div>
<div>var request = new actuate.data.Request("bookmarkName",1,100);</div>
<div>dataservice.downloadResultSet(file, request, displayData, errorHandler);</div>
<div>alert("At the end.");</div>
<div>}</div>
<div> </div>
<div>function displayData(rs)</div>
<div>{</div>
<div>alert("In Display Data");</div>
<div>var columns = rs.getColumnNames( );</div>
<div>while (rs.next( )){</div>
<div>for (var i = 0; i < columns.length; i++){</div>
<div>document.writeln(rs.getValue(columns));</div>
<div>}</div>
<div>}</div>
<div>}</div>
<div> </div>
<div>function errorHandler(exception)</div>
<div>{</div>
<div>alert("Your application encountered an exception: \n" +<span> </span>exception.getMessage());</div>
<div>}</div>

Comments

  • <p>I think  I have used .setCustomParameters incorrectly and looks like it may not be possible to pass parameters when downloading resultset from a report.</p>
  • <p>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()).</p>
  • Clement Wong
    Clement Wong E mod
    edited December 12, 2016 #4
    <p>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. </p>
    <p> </p>
    <p>What's the ultimate goal other than "I need to create a script that reads data from this report and stores it in database."</p>
    <p> </p>
    <p>You can add code into your report design that writes to the database.</p>
    <p> </p>
    <p>If you have specific parameters, you'll first need to run a .RPTDESIGN and then with the .RPTDOCUMENT extract the data.</p>
    <p> </p>
    <p>The REST API also provides this service and allows you to extract data from a materialized Data Object (.DATA) via /dataobject/dataExtraction.</p>
    Warning No formatter is installed for the format ipb
  • <p>Thanks Clement for your help.</p>
    <p> </p>
    <p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">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</span></p>
    <p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">--> 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.</span></p>
    <p> </p>
    <p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">You can add code into your report design that writes to the database</span></p>
    <p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">-->I don't have access to or control over report design</span></p>
    <p> </p>
    <p>My ultimate goal:</p>
    <p>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. </p>
  • <p>One option:</p>
    <p>In the iHub, you can schedule the .RPTDESIGN to generate the .RPTDOCUMENT.</p>
    <p> </p>
    <p>Then, you can schedule your .NET app to read from the the .RPTDOCUMENT to write to the Oracle table.</p>
    <p> </p>
    <p> </p>
    <p>Another option as suggested previously.</p>
    <p>Add logic into your .RPTDESIGN to write to the Oracle table.  In the iHub, schedule the .RPTDESIGN as needed.</p>
    Warning No formatter is installed for the format ipb