Hi :)
I want to generate a report for each object (from the table) in one report.
I have something like that:
function createSection( p_aGroup) { for(var i=0; i<p_aGroup.length; i++) { iteration_group(ArisData.sort(p_aGroup[i].ObjDefList(true, [Constants.OT_FUNC_CLUSTER]),Constants.AT_NAME, nLocale)) } function iteration_group(p_aObjDef) { for(var i1=0; i1<p_aObj.length; i1++) { var report = Context.getComponent("Report") var tab = new Array(); tab[0] = p_aObj[i1]; var reportInfo = report.createExecInfo("_A/583672a0-0b40-11df-7c8f-001a4b5ed64c", tab, nLocale, Constants.OUTWORD, "C:/Users/kb/Desktop/Stuff/test.doc") var result = report.execute(reportInfo); var plik = result.getResultFileData(); plik[0].getName(); } } }
but it doesn't work. What I'm doing wrong? plz help!
Hi Katarzyna,
this cannot work, because you have specified a client path for the report result and you do not transfer the result to the calling client.
Reports are executed on server side, so you cannot expect, that the result is created on a client path. The file name you specify here can be used by Context.getSelectedPath()/Context.getSelectedFile(), but this file is not created.
The result file can be accessed (as you're doing right in your script) by calling result.getResultFileData(). The main report now has to make sure, that all results are copied to the client correctly, so they have to be added to the "files to be transferred to the client" like this:
[line16] for(var i2=0; i2<plik.length; i2++) {
Context.addOutputFile(plik[i2].getName(), plik[i2].getData() )
}
...and make sure that all output files have different names, for example by using the GUID (or Name) of the object definition as part of the file name.
BR,
Torsten
Hello. I realize this post is a little old, but I am trying to accomplish the same exact thing. I have a report that I execute another report that generates an Excel file. I have tried Torsten's suggestion, but I still do not see any file generated. My code is something like this:
function createReport(scriptID, objObjects, language, outputFormat, outputFilename) { var oReportComponent = Context.getComponent("Report") var reportExecData = oReportComponent.createExecInfo(scriptID, objObjects, language, outputFormat, outputFilename) var result = oReportComponent.execute(reportExecData) var file = result.getResultFileData() Context.addOutputFile("C:/temp/" + file[0].getName(), file[0].getData()) }
Hello Torsten,
Thanks for the reply. I tried different things yesterday after I posted the question. It turned out that the report script was not enabled for output. I had done like you said by not adding the path and it was still not working. After I checked "Create output file" in the properties of the report script it finally wrote the file. I am now using Context.setSelectedPath(outputPath) to define my path and then Context.addOutputFile(file[0].getName(), file[0].getData()).
Thanks for your help!
Allen