Report Generation

Contents Hide

  

Reports may be generated server-side on BrightServer instances using BrightServer Scripts and methods. This will create PDF reports on the server's file system using BrightXpress' Report framework. These reports may then be used for other back-end processes, or synchronised back to devices, typically with the externalBlob data type.

BrightXpress' Report framework, also found in BSP projects, consist of Table, Query and Report elements. With these defined, the reports may be generated via BrightServer script. These concepts are described in the sections below.

Table Definition

Reports will display a set of data on a set of tables defined for the project. These tables are defined in the Tables node of the BEP, and creating or tapping on tables under this node will open Table Editor, as in BSP projects. These tables are also used when defining sync point sources/destinations, and mappings for the server.

For more information, please refer to BrightServer > Tables, and BrightBuilder > Tables sections of this document.

For BrightServer reports, by default these tables will be read from the server's default data source, defined in the BEP's sync panels. If a default data source is not found, the report generation will fail in the BrightServer script. If another data source is to be used, the setDataSource() method may be called prior to generating the report.

Query Specification

The set of data from the tables in the project are defined by Queries, and may be on set or parameterised conditions for table data. Queries should be limited to standard or advanced types for BrightServer reports. These queries may be found under the Queries node of the BEP project, are defined exactly the same way with the BSP Query Editor, and are even able to be directly copied and pasted to/from existing BSPs.

For more information on queries, please refer to the BrightBuilder > Queries section of this document.

Report Definition

The Reports node in BEPs detail the layout of reports which the server may generate. Multiple reports may exist for a BEP project, and tapping reports defined under this node will open the report's layout for editing in the Report WYSIWYG editor. This editor is also laid out the same way as in BSPs, featuring drag and drop positioning of fields in the layout. Reports may also be copied directly to/from BSP projects.

Briefly,

For more information on configuring reports in BrightBuilder, please refer to the BrightBuilder > Reports section of this document.

Despite displaying in the WYSIWYG, not all fonts are available, and may not appear as rendered in the resulting PDF report. With fonts, only Helvetica, Courier and Times are offered, and fonts will render in these styles if their Font Family contains these names. Otherwise, the default font will be Helvetica.

Script Methods

With Table, Query and Report definitions in the BEP project, a Report object may be instantiated via the ScriptSession.createReportObject() method in a BrightServer Script to configure and print the PDF report. Parameters for this object may be set via the setQueryParam() method, while variables may be set with setVariable(). If the data source to be queried isn't the default in the BEP, the setDataSource() method may be called to specify the data source.

After this, the printToPDF() method may be called naming the report and file output path. Once complete, the Report object may be closed with the close() method.

The following example will print the "rptTest" report to file ("C:\Temp\temp.pdf") after setting a set of variables and parameters:

var rptTest = ScriptSession.createReportObject();

try

{

var strVal = "String";

var blnVal = true;

var dblVal = 2.33;

var intVal = new Integer(42);

var dtVal = Calendar.getInstance();

dtVal.add(Calendar.MONTH, -12);

 

rptTest.setVariable("Variable1", strVal);

rptTest.setVariable("Variable2", blnVal);

rptTest.setVariable("Variable3", intVal);

rptTest.setVariable("Variable4", dblVal);

rptTest.setVariable("Variable5", dtVal.getTime());

rptTest.setVariable("Variable6", null);

 

rptTest.setQueryParam("pDateGtEq", dtVal.getTime());

rptTest.setPageSize (210, 297);

 

rptTest.setDataSource("SyncPoint1_Database3");

rptTest.printToPDF("rptTest", "C:\\Temp\\temp.pdf");

}

catch (error)

{

ScriptSession.logError("Error generating PDF file : " + error) ;

}

finally

{

if (rptTest !== null)

{

rptTest.close();

}

}

Please note the following: