Context Availability
| Template | Velocity Context Available | Notes |
|---|
risksheetTopPanel.vm (top panel configuration) | Yes | Full context with Polarion services, document, and Velocity tools |
risksheetPdfExport.vm (PDF export configuration) | Yes | Full context plus pdfExportMacros.vm helpers |
| Sheet configuration | Yes (since v25.4.0) | Velocity expressions evaluated during configuration parsing |
Since version 25.4.0, the Velocity context is also available in the sheet configuration. This enables dynamic configuration values driven by Polarion services such as $repositoryService.
Document Objects
| Variable | Type | Description |
|---|
$document | Polarion Module | The current Polarion document (module) object |
$doc | Polarion Module | Alias for $document, provides access to document API |
$transaction | Transaction | Current Polarion transaction for data operations |
$item | Work Item | Current work item context (available in serverRender column templates) |
Accessing Document Custom Fields
Use $document.customFields to read document-level custom fields in the top panel.
## Display a document custom field in the top panel
<div>Product Family: $document.customFields.productFamily</div>
Use $doc.getOldApi().getValue('customFieldID') for programmatic access to custom field values.
## Access custom field via Old API
#set($riskAcceptance = $doc.getOldApi().getValue("riskAcceptanceMatrix"))
<script>
var riskMatrix = "$riskAcceptance";
</script>
The top panel can display document custom fields using Velocity but cannot currently modify them. Custom field modification requires Polarion’s standard document editing interface.
Polarion Services
| Variable | Type | Description |
|---|
$repositoryService | Repository Service | Access to Polarion repository operations for querying work items and documents |
$securityService | Security Service | Returns the current user and role membership (top panel) |
$testManagementService | Test Management Service | Retrieves test execution records for a work item (serverRender) |
$securityService — Current User and Roles
Available in risksheetTopPanel.vm. Provides identity information for role-based UI logic such as conditional rendering or per-role default views.
## Resolve current user and their Polarion roles
#set($user = $securityService.getCurrentUser())
#set($roles = $securityService.getRolesForUser($user))
<script>
var currentUser = "$user";
var userRoles = "$roles";
// Example: load a different default saved view for reviewers
if (userRoles.indexOf("reviewer") !== -1) {
risksheet.appConfig.views[2].defaultView = true;
}
</script>
$testManagementService — Test Execution Records
Available in serverRender column templates. Use it to surface the latest test execution outcome next to a risk item or requirement.
## Get last test execution result for the current work item
#macro(getLastTestRecord $item)
#set($testRecords = $testManagementService.getLastTestRecords($item.getOldApi(), 1))
#foreach($iRecord in $testRecords)
#set($testRun = $transaction.testRuns().getBy().oldApiObject($iRecord.getTestRun()))
$iRecord.getTestRun().getId() - $iRecord.getResult().name
#end
#end
#getLastTestRecord($item)
The complete list of Polarion services in the Velocity context depends on your Polarion version and Risksheet release. Verify availability in your deployment.
Top Panel Context
The top panel Velocity template (risksheetTopPanel.vm) renders HTML above the Risksheet grid via the /api/panel endpoint. The template has full access to Polarion services and document context.
JavaScript functions defined in the top panel <script> block can be called from formulas in the sheet configuration.
## In risksheetTopPanel.vm
#set($matrixData = $doc.getOldApi().getValue("riskAcceptanceMatrix"))
<script>
function getRiskAcceptance(severity, occurrence) {
var matrix = JSON.parse('$matrixData');
return matrix[severity][occurrence];
}
</script>
formulas:
riskAcceptance: "function(info) { return getRiskAcceptance(info.item['severity'], info.item['occurrence']); }"
Referencing External Data Sources
The top panel can reference external data sources via Velocity context and Polarion APIs, enabling dynamic risk matrix definitions shared across projects.
## Load risk matrix from external XML configuration
#set($avasisConfig = $repositoryService.getConfigurationService().getXmlConfig("avasis"))
<script>
var dynamicMatrix = $avasisConfig.toJson();
</script>
PDF Export Context
The PDF export Velocity template (risksheetPdfExport.vm) receives the full Velocity context plus helper macros.
| Additional Context | Description |
|---|
pdfExportMacros.vm | Helper macros for PDF-specific formatting and layout |
revision parameter | Required parameter specifying which document revision to export |
See PDF Export Template for template structure and PDF Export API for the JavaScript export methods.
Sheet Configuration Context
Since version 25.4.0, Velocity expressions in the sheet configuration are evaluated during configuration loading. This enables dynamic values for project references, document fields, and conditional configuration.
dataTypes:
task:
type: $velocityExpression
The exact Velocity expressions supported in the sheet configuration and their evaluation order should be verified against your Risksheet version. Not all configuration properties may support Velocity evaluation.
Error Handling
| Scenario | Behavior |
|---|
| Template rendering error | Red error message box displayed in place of the panel |
| Missing template file | Default empty panel rendered |
| Velocity syntax error | Error details rendered as HTML in the panel area |
Related Pages