Writing a Report
Reports in versaSRS are written in XML format and use an SQL query to return the data. The Report parameters can be passed to the query to execute based on the parameter selections.
The basic XML-style syntax of a report is presented below:
The elements of the Report are outlined below:
- ReportTitle: The Main Report Title, displayed at the top of the report, can include HTML markup*
- ReportHeader: The Report Header, displayed under the Report Title and just before the report output, can include HTML markup*
- ReportFooter: The Report Footer, displayed under the report output, can include HTML markup*
- Parameters: Defines a list of optional parameters that are available to the operator when running the report
- Queue: Defines whether the Team list is available to the operator, must be set to either true or false**
- SkillGroup: Defines whether the Skill Group list is available to the operator, must be set to either true or false**
- User: Defines whether the User list is available to the operator, must be set to either true or false**
- CallType: Defines whether the Case Type list is available to the operator, must be set to either true or false**
- ReceivedBy: Defines whether the Received By list is available to the operator, must be set to either true or false**
- Status: Defines whether the Status list is available to the operator, must be set to either true or false**
- Priority: Defines whether the Priority list is available to the operator, must be set to either true or false**
- Key1: Defines whether the Key 1 list is available to the operator, must be set to either true or false**
- Key2: Defines whether the Key 2 list is available to the operator, must be set to either true or false**
- Key3: Defines whether the Key 3 list is available to the operator, must be set to either true or false**
- Title: Defines the title of the Report, displayed directly above the report output defined by the element Query, can include HTML markup*
- Totals: Defines whether the report will support column totals, must be set to either true or false**
- Query: Defines the SQL syntax of the report
- Columns: Optionally defines the visibility, headings, and totals on each of the output columns. The number of columns specified here needs to match the number of columns returned by the query or you will get an error.
*Because the Report is based on an XML document, you must make sure that the HTML is valid XML. Enclosing any HTML within a CDATA section will prevent any unexpected interpretation of HTML tags.
**If a value is not set, the system will apply the default value of false.
My Company
My Company
The following example shows how to construct a basic report showing the Current Cases for the Help Desk Team.
While the basic report XML structure could be suitable for many reports, there is also additional functionality and flexibility available with more advanced Report XML.
Parameter Queries
A Parameter Query can be used within a report to extract data parameters and then resolve the parameters in the Report Query. The Parameter Query is specified within the <ParametersQuery></ParametersQuery> XML tag and is resolved in the Report Query with the [QPARAM1] tag. Each parameter that is output from the Parameter Query corresponds to the [QPARAMX] tags as in [QPARAM1], [QPARAM2], [QPARAM3]... and so on. Within the <Report></Report> xml tags the <UserParameterQuery>true</UserParameterQuery> xml tag must be specified if it is to resolve the output from the Parameter Query.
Multiple Reports
Each report is defined by the <Report>...</Report> tags and multiple reports can be added to a single XML structure by stacking the reports. The example below shows how to construct a report that contains two reports, Cases Logged For The Period and Cases Closed For The Period:
Report Table
The table parameter specifies properties for the data output table and is defined with the <Table></Table> tag. Setting the value to false will result in the table not being displayed.
The following properties can be configured within the tag:
position | Text value defining the position of the table relative to the chart (above, below) |
width | Integer value that specifies the width of the table |
Sub Report Table
A table parameter within a Sub Report is used to set the properties for how it will be displayed.
The following properties can be configured within the tag:
indentwidth | Integer value that specifies how many pixels to indent the Sub Report in comparison to the Main Report |
width | Integer value that specifies the width of the table |
displayheading | Boolean value to display the heading for the Sub Report table or not (true or false) |
Report Charting
Charting with graphs can be added to reports using the <ChartData>true</ChartData> tags. Setting the value to false will result in the chart not being displayed.
The following properties can be configured within the tag:
engine | Integer value that defines the charting engine (1, 2, 3) |
type | Text value defining the type of chart to display (bar, column, pie, line, funnel) |
seriescolours | This attribute expects HEX colour code to represent each series. These colours can be overridden in versaBoard. |
enable3D | Boolean value to display the chart in 3D or 2D (true or false) |
xaxislabel | Text value defining the label for the x axis |
yaxislabel | Text value defining the label for the y axis |
xcol1 to xcolx | Integer value defining which column in the Report Query output will be used for the corresponding x axis data set |
ycol1 to ycolx | Integer value defining which column in the Report Query output will be used for the corresponding y axis data set |
width | Integer value defining the width of the graph |
height | Integer value defining the height of the graph |
stacked | Boolean value defining whether the charting should be stacked against each other or not (true or false) |
stacked100 | Boolean value defining whether to display as percentage or values (true or false) |
plotlabel | Boolean value defining whether to display value inside the chart or not (true or false) |
xaxislabelangle | Integer value defining the angle in degrees to label the text |
yaxislabelangle | Integer value defining the angle in degrees to label the text |
Totals
A Totals row or column can be applied to sum the values in the row or column and display the total on the report output. This can be achieved by adding the <Totals>true</Totals> tag within the <Report></Report> tag with the appropriate properties set.
The following properties can be configured within the tag:
rowheading | Text value specifying the row heading |
columnheading | Text value specifying the column heading |
rows | Text value of 'hidden' or 'visible' to set whether to display the row |
columns | Text value of 'hidden' or 'visible' to set whether to display the column |
Aggregate Queries
Aggregate Queries can be used to append data sets from multiple queries together in a single table. To use Aggregate Queries the <AggregateQuery></AggregateQuery> must be specified within the <Report></Report> tag and the Queries within must each be specified within a <Query></Query> tag (see report template below).
Sub Reports
Sub Reports can be included in the XML structure with a drill down feature to show/hide the sub report. The Sub Report is defined by the <SubReport></SubReport> tags. By using the tags such as [DATA1] can be used to create the relevant link to the parent report to the sub report. Please see below example.
Report Template Example
The following example is not a working Report but a template showing how the parameters can be configured.