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:

Example: Report Structure <Reporting> <ReportTitle></ReportTitle> <ReportHeader></ReportHeader> <ReportFooter></ReportFooter> <Parameters> <Queue></Queue> <SkillGroup></SkillGroup> <User></User> <CallType></CallType> <ReceivedBy></ReceivedBy> <CallStatus></CallStatus> <Priority></Priority> <Key1></Key1> <Key2></Key2> <Key3></Key3> </Parameters> <Report> <Title></Title> <Totals></Totals> <Query></Query> <Columns></Columns> </Report> </Reporting>

The elements of the Report are outlined below:

*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.

Example: Valid HTML Formatting <ReportTitle>My Report<br>My Company</ReportTitle> This is invalid <ReportTitle>My Report<br />My Company</ReportTitle> This is valid <ReportTitle><![CDATA[My Report<br/>My Company]]></ReportTitle> This is valid

The following example shows how to construct a basic report showing the Current Cases for the Help Desk Team.

Example: Basic Report <Reporting> <ReportTitle>Current Cases For Help Desk Team</ReportTitle> <ReportHeader></ReportHeader> <ReportFooter></ReportFooter> <Parameters> <CallType></CallType> <ReceivedBy></ReceivedBy> <ProductType></ProductType> <Product></Product> <Impact></Impact> <ServiceArea></ServiceArea> <SymptomCode></SymptomCode> <CauseCode></CauseCode> <Queue></Queue> <SkillGroup></SkillGroup> <User></User> <CallStatus></CallStatus> <Urgency></Urgency> <Risk></Risk> <Priority></Priority> <Key1></Key1> <Key2></Key2> <Key3></Key3> </Parameters> <Report> <Title>Current Cases</Title> <Totals></Totals> <Query>SELECT CallID, Subject FROM tbl_Calls WHERE QueueID = 1 AND CallStatusID IN (1, 2, 4, 7)</Query> <Columns></Columns> </Report> </Reporting>

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.

Example: Parameter Query <Reporting> <ParametersQuery> SELECT QueueID, QueueName FROM tbl_Queues WHERE QueueStatus = 1 AND QueueID IN (1,2,3,4) </ParametersQuery> <Report> <UseParametersQuery>true</UseParametersQuery> <Title>[SYSLABEL1] Details for "[QPARAM2]" [SYSLABEL8]</Title> <Table position="above" width="750">true</Table> <Query> <![CDATA[ SELECT TOP 100 CallID, Subject, CallStatusTitle, DateEntered, DueDate, QueueName, GroupName, FirstName, LastName, Email FROM tbl_Calls INNER JOIN tbl_Queues ON tbl_Queues.QueueID = tbl_Calls.QueueID INNER JOIN tbl_CallStatus ON tbl_CallStatus.CallStatusID = tbl_Calls.CallStatusID LEFT OUTER JOIN tbl_Groups ON tbl_Groups.GroupID = tbl_Calls.GroupID WHERE tbl_Calls.QueueID = [QPARAM1] AND tbl_Calls.CallStatusID IN (1,2,4,5,7) AND tbl_Calls.DateEntered BETWEEN '[STARTDATE1]' AND '[ENDDATE1] 23:59:59' ]]> </Query> </Report> </Reporting>

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:

Example: Multiple Reports <Reporting> <ReportTitle>Case Logging Summary Report</ReportTitle> <ReportHeader></ReportHeader> <ReportFooter></ReportFooter> <Parameters> <CallType></CallType> <ReceivedBy></ReceivedBy> <ProductType></ProductType> <Product></Product> <Impact></Impact> <ServiceArea></ServiceArea> <SymptomCode></SymptomCode> <CauseCode></CauseCode> <Queue>true</Queue> <SkillGroup></SkillGroup> <User></User> <CallStatus></CallStatus> <Urgency></Urgency> <Risk></Risk> <Priority></Priority> <Key1></Key1> <Key2></Key2> <Key3></Key3> </Parameters> <Report> <Title>Cases Logged For The Period [STARTDATE1] to [ENDDATE1]</Title> <Totals></Totals> <Query> SELECT Count(tbl_Calls.CallID) FROM tbl_Calls WHERE (tbl_Calls.DateEntered BETWEEN '[STARTDATE1] 00:00:00' AND '[ENDDATE1] 23:59:59') AND tbl_Calls.QueueID = [PARAM1] </Query> <Columns> <column id="1" visible="true">No. of Cases Logged</column> </Columns> </Report> <Report> <Title>Cases Closed For The Period [STARTDATE1] to [ENDDATE1]</Title> <Totals></Totals> <Query> SELECT Count(tbl_Calls.CallID) FROM tbl_Calls WHERE (tbl_Calls.DateEntered BETWEEN '[STARTDATE1] 00:00:00' AND '[ENDDATE1] 23:59:59') AND DATEDIFF(ss, tbl_Calls.Closed, tbl_Calls.DueDate) >= 0 AND tbl_Calls.QueueID = [PARAM1] </Query> <Columns> <column id="1" visible="true">No. Of Cases Logged And Closed Prior To Due Date</column> </Columns> </Report> </Reporting>

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
Example: Report Table Syntax <Report> <Table position="above|below" width="750">true|false</Table> </Report>

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)
Example: Sub Report Table <SubReport> <Table indentwidth="24" width="500" displayheading="true|false">true|false</Table> <ExpandDisplay>true|false</ExpandDisplay> </SubReport>

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
Example: Charting Syntax <Report> <ChartData engine="1|2|3" type="pie|bar|column|line|funnel" seriescolours="#1AD21A,#B3B5CE,#FF1A1A" enable3d="true|false" xaxislabel="" yaxislabel="" xcol="" ycol1="" width="100" height="100" perimeter="20">true|false</ChartData> </Report>

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
Example: Totals Syntax <Report> <Totals rowheading="PLAIN TEXT" columnheading="PLAIN TEXT" rows="visible|hidden" columns="visible|hidden">true|false</Totals> </Report>

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).

Example: Aggregate Queries <Reporting> <Report> <UseParametersQuery>true|false</UseParametersQuery> <Title>My First Aggregate Query Report</Title> <Query> <![CDATA[ ]]> </Query> <AggregateQuery> <Query></Query> <Query></Query> <Query></Query> </AggregateQuery> <Columns> <column id="1" visible="true|false" width="100" align="left|right|center" nowrap="true|false" prefix="" suffix="" href="" charttype="bar|column|line" threshold1="" total="true|false" target="">[SYSLABEL2]</column> </Columns> <SubReport> <Table indentwidth="24" width="500" displayheading="true|false">true|false</Table> <ExpandDisplay>true|false</ExpandDisplay> <Query> <![CDATA[ ]]> </Query> <Columns> <column id="1" visible="true|false" width="100" align="left|right|center" nowrap="true|false" prefix="" suffix="" href="" charttype="bar|column|line" threshold1="" total="true|false" target="">All</column> </Columns> </SubReport> </Report> </Reporting>

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.

Example: Sub Reports <Reporting> <ReportTitle /> <ReportHeader> <span class="heading1" style="padding-left: 5px;">Project Timeline Report</span> </ReportHeader> <Parameters> <CallType></CallType> <ReceivedBy></ReceivedBy> <ProductType></ProductType> <Product></Product> <Impact></Impact> <ServiceArea></ServiceArea> <SymptomCode></SymptomCode> <CauseCode></CauseCode> <Queue>true</Queue> <SkillGroup></SkillGroup> <User></User> <CallStatus></CallStatus> <Urgency></Urgency> <Risk></Risk> <Priority></Priority> <Key1></Key1> <Key2></Key2> <Key3></Key3> </Parameters> <Report> <Title> </Title> <Table width="750">true</Table> <Query> <![CDATA[ SELECT DISTINCT CallID As HiddenID, CallID, Subject, CallStatusTitle, Product, DateEntered, DueDate, (CASE WHEN DueDate < GETDATE() THEN '100%' ELSE CONVERT(varchar(6), CAST(CAST((1.0 - (CAST(DATEDIFF(MINUTE, GETDATE(), DueDate) As Decimal(12, 2)) / CAST(DATEDIFF(MINUTE, DateEntered, DueDate) As Decimal(12,2)))) * 100.0 As Decimal(5,2)) As varchar) + '%') END) As PercentDue FROM tbl_Calls INNER JOIN tbl_CallStatus ON tbl_CallStatus.CallStatusID = tbl_Calls.CallStatusID LEFT OUTER JOIN tbl_Product ON tbl_Product.ProductID = tbl_Calls.ProductID WHERE tbl_Calls.CallStatusID IN (1,2,4,5,7) AND QueueID = [PARAM1] AND CallID IN (SELECT CallPID FROM tbl_Calls WHERE tbl_Calls.CallStatusID IN (1,2,4,5,7)) ORDER BY tbl_Calls.CallID ]]> </Query> <Columns> <column width="0" id="1" visible="false">HiddenID</column> <column width="60" id="2" visible="true" href="javascript:cmdGotoCall('[DATA1]', 1);">[SYSLABEL2]</column> <column width="300" id="3" visible="true">Subject</column> <column width="100" id="4" visible="true">Status</column> <column width="130" id="5" visible="true">Senior Leader</column> <column width="120" id="6" visible="false">Logged Date</column> <column width="120" id="7" visible="true">Due Date</column> <column width="200" id="8" visible="true" threshold1="0%,#5EFF61" charttype="bar" threshold3="50%,#FFD454" threshold2="25%,#9ae639">Timeline</column> </Columns> <SubReport> <ExpandDisplay>true</ExpandDisplay> <Table width="100%" displayheading="false" indentwidth="24">true</Table> <Query> <![CDATA[ SELECT CallID As HiddenID, CallID, Subject, CallStatusTitle, Product, DateEntered, DueDate, (CASE WHEN DueDate < GETDATE() THEN '100%' ELSE CONVERT(varchar(6), CAST(CAST((1.0 - (CAST(DATEDIFF(MINUTE, GETDATE(), DueDate) As Decimal(12, 2)) / CAST(DATEDIFF(MINUTE, DateEntered, DueDate) As Decimal(12,2)))) * 100.0 As Decimal(5,2)) As varchar) + '%') END) As PercentDue FROM tbl_Calls INNER JOIN tbl_CallStatus ON tbl_CallStatus.CallStatusID = tbl_Calls.CallStatusID LEFT OUTER JOIN tbl_Product ON tbl_Product.ProductID = tbl_Calls.ProductID WHERE tbl_Calls.CallStatusID IN (1,2,4,5,7) AND tbl_Calls.CallPID = [DATA1] ORDER BY tbl_Calls.CallID ]]> </Query> <Columns> <column width="24" id="1" visible="false">HiddenID</column> <column width="60" id="2" visible="true" href="javascript:cmdGotoCall('[DATA1]', 1);">[SYSLABEL2]</column> <column width="325" id="3" visible="true">Subject</column> <column width="120" id="4" visible="true">Status</column> <column width="130" id="5" visible="true">Senior Leader</column> <column width="130" id="6" visible="false">Logged Date</column> <column width="130" id="7" visible="true">Due Date</column> <column width="200" id="8" visible="true" threshold1="0%,#5EFF61" charttype="bar" threshold3="50%,#FFD454" threshold2="25%,#9ae639">Timeline</column> </Columns> </SubReport> </Report> <ReportFooter> </ReportFooter> </Reporting>

Report Template Example

The following example is not a working Report but a template showing how the parameters can be configured.

Example: Full Report Structure <Reporting> <DateFormat>dd-MM-yyyy hh:mm:ss tt</DateFormat> <ReportTitle>My First versaSRS Report</ReportTitle> <ReportHeader> You can add embedded css style using <style></style> tag You can add custom javascript using <versaScript></versaScript> tag </ReportHeader> <Parameters> <CallType>true|false</CallType> <ReceivedBy>true|false</ReceivedBy> <ProductType>true|false</ProductType> <Product>true|false</Product> <Impact>true|false</Impact> <ServiceArea>true|false</ServiceArea> <SymptomCode>true|false</SymptomCode> <CauseCode>true|false</CauseCode> <Queue>true|false</Queue> <SkillGroup>true|false</SkillGroup> <User>true|false</User> <CallStatus>true|false</CallStatus> <Urgency>true|false</Urgency> <Risk>true|false</Risk> <Priority>true|false</Priority> <Key1>true|false</Key1> <Key2>true|false</Key2> <Key3>true|false</Key3> </Parameters> <ParametersQuery> <![CDATA[ ]]> </ParametersQuery> <Report> <UseParametersQuery>true|false</UseParametersQuery> <Title></Title> <Table position="above|below" width="750">true|false</Table> <ChartData engine="1|2|3" type="pie|bar|column|line|funnel" enable3d="true|false" xaxislabel="" yaxislabel="" xcol="" ycol1="" width="100" height="100" perimeter="20">true|false</ChartData> <Totals rowheading="PLAIN TEXT" columnheading="PLAIN TEXT" rows="visible|hidden" columns="visible|hidden">true|false</Totals> <Query> <![CDATA[ ]]> </Query> <AggregateQuery> <Query> </Query> <Query> </Query> <Query> </Query> </AggregateQuery> <Columns> <column id="1" visible="true|false" width="100" align="left|right|center" nowrap="true|false" prefix="" suffix="" href="" charttype="bar|column|line" threshold1="" total="true|false" target="">[SYSLABEL2]</column> </Columns> <SubReport> <Table indentwidth="24" width="500" displayheading="true|false">true|false</Table> <ExpandDisplay>true|false</ExpandDisplay> <Query> <![CDATA[ ]]> </Query> <Columns> <column id="1" visible="true|false" width="100" align="left|right|center" nowrap="true|false" prefix="" suffix="" href="" charttype="bar|column|line" threshold1="" total="true|false" target="">All</column> </Columns> </SubReport> </Report> <ReportFooter></ReportFooter> </Reporting>