Create a report:
This article assumes you are familiar with the basics of writing custom reports in Spira.
In this example we will create a custom report based on the standard Incident Summary report so to include missing tags information.
To clone the standard report you need to:
- Go to Administration > Edit Reports
- Click on Clone next to the standard report you need to get modified
- Click Edit next to the newly created report
- Give it a meaningful name or leave it as is (ClonedReportName - Copy)
- Specify allowed file formats report generation: MS-Word, Excel, HTML or PDF formats
- Click Customize under the standard section's Incident List entry:
Modify the XSLT:
The target code located under the Template section of the window opened:
If you'd like to modify the XSLT code by yourself (or may need to add additional changes), it can be easier to edit the code in dedicated editor so copy and paste it for that.
Otherwise, just copy and paste the code given below:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:template match="/IncidentData">
<table class="DataGrid" style="width:100%">
<tr>
<th>Inc #</th>
<th>Name</th>
<th>Description</th>
<th>Resolution</th>
<th>Type</th>
<th>TAGS</th>
<th>Status</th>
<th>Priority</th>
<th>Severity</th>
<th>Detected By</th>
<th>Owned By</th>
<th>Detected On</th>
<th>Last Modified</th>
<th>Closed On</th>
<th>Detected Release</th>
<th>Planned Release</th>
<th>Verified Release</th>
<th>Fixed Build</th>
<th>Component(s)</th>
<th>% Complete</th>
<th>Est. Effort</th>
<th>Actual Effort</th>
<th>Remaining Effort</th>
<th>Projected Effort</th>
<xsl:for-each select="Incident[1]/CustomProperties/CustomProperty">
<th>
<xsl:value-of select="Alias"/>
</th>
</xsl:for-each>
</tr>
<xsl:for-each select="Incident">
<tr>
<td>
<xsl:value-of select="IncidentId"/>
</td>
<td>
<xsl:value-of select="Name"/>
</td>
<td>
<xsl:value-of select="Description" disable-output-escaping="yes"/>
</td>
<td>
<xsl:value-of select="IncidentResolutions/IncidentResolution[last()]/Resolution" disable-output-escaping="yes"/>
</td>
<td>
<xsl:value-of select="IncidentTypeName"/>
</td>
<td>
<xsl:value-of select="Tags"/>
</td>
<td>
<xsl:value-of select="IncidentStatusName"/>
</td>
<td>
<xsl:value-of select="PriorityName"/>
</td>
<td>
<xsl:value-of select="SeverityName"/>
</td>
<td>
<xsl:value-of select="OpenerName"/>
</td>
<td>
<xsl:value-of select="OwnerName"/>
</td>
<td class="Date">
<xsl:call-template name="format-date">
<xsl:with-param name="datetime" select="CreationDate" />
</xsl:call-template>
</td>
<td class="Date">
<xsl:call-template name="format-date">
<xsl:with-param name="datetime" select="LastUpdateDate" />
</xsl:call-template>
</td>
<td class="Date">
<xsl:call-template name="format-date">
<xsl:with-param name="datetime" select="ClosedDate" />
</xsl:call-template>
</td>
<td>
<xsl:value-of select="DetectedReleaseVersionNumber"/>
</td>
<td>
<xsl:value-of select="ResolvedReleaseVersionNumber"/>
</td>
<td>
<xsl:value-of select="VerifiedReleaseVersionNumber"/>
</td>
<td>
<xsl:value-of select="BuildName"/>
</td>
<td>
<xsl:value-of select="ComponentNames"/>
</td>
<td>
<xsl:value-of select="CompletionPercent"/>%
</td>
<td class="Timespan">
<xsl:value-of select="EstimatedEffort"/>
</td>
<td class="Timespan">
<xsl:value-of select="ActualEffort"/>
</td>
<td class="Timespan">
<xsl:value-of select="RemainingEffort"/>
</td>
<td class="Timespan">
<xsl:value-of select="ProjectedEffort"/>
</td>
<xsl:for-each select="CustomProperties/CustomProperty">
<xsl:choose>
<xsl:when test="Type='Date'">
<td class="Date">
<xsl:call-template name="format-date">
<xsl:with-param name="datetime" select="Value" />
</xsl:call-template>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="Value" disable-output-escaping="yes" />
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template name="format-date">
<xsl:param name="datetime"/>
<xsl:variable name="date" select="substring-before($datetime, 'T')" />
<xsl:variable name="year" select="substring-before($date, '-')" />
<xsl:variable name="month" select="substring-before(substring-after($date, '-'), '-')" />
<xsl:variable name="day" select="substring-after(substring-after($date, '-'), '-')" />
<xsl:variable name="time" select="substring-before(substring-after($datetime, 'T'), '.')" />
<xsl:variable name="monthname">
<xsl:choose>
<xsl:when test="$month='01'">
<xsl:value-of select="'Jan'"/>
</xsl:when>
<xsl:when test="$month='02'">
<xsl:value-of select="'Feb'"/>
</xsl:when>
<xsl:when test="$month='03'">
<xsl:value-of select="'Mar'"/>
</xsl:when>
<xsl:when test="$month='04'">
<xsl:value-of select="'Apr'"/>
</xsl:when>
<xsl:when test="$month='05'">
<xsl:value-of select="'May'"/>
</xsl:when>
<xsl:when test="$month='06'">
<xsl:value-of select="'Jun'"/>
</xsl:when>
<xsl:when test="$month='07'">
<xsl:value-of select="'Jul'"/>
</xsl:when>
<xsl:when test="$month='08'">
<xsl:value-of select="'Aug'"/>
</xsl:when>
<xsl:when test="$month='09'">
<xsl:value-of select="'Sep'"/>
</xsl:when>
<xsl:when test="$month='10'">
<xsl:value-of select="'Oct'"/>
</xsl:when>
<xsl:when test="$month='11'">
<xsl:value-of select="'Nov'"/>
</xsl:when>
<xsl:when test="$month='12'">
<xsl:value-of select="'Dec'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="''" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat($day, '-' ,$monthname, '-', $year , ' ', $time)" />
</xsl:template>
</xsl:stylesheet>
Click Save twice and now your custom report is ready for use.
Explanation of changes:
In this example we just added few new lines of the code, so to generate new column with tags associated with given incident.
1. Code line to generate new empty column - line 11:
<th>TAGS</th>
2. Code to pull the data from database and get it in the column we created above - line 53-54-55:
<td>
<xsl:value-of select="Tags"/>
</td>
Sample Report
Once ready and changes saved, you can run the report from the Report Center: