Skip to main content
diagram

Context Availability

TemplateVelocity Context AvailableNotes
risksheetTopPanel.vm (top panel configuration)YesFull context with Polarion services, document, and Velocity tools
risksheetPdfExport.vm (PDF export configuration)YesFull context plus pdfExportMacros.vm helpers
Sheet configurationYes (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

VariableTypeDescription
$documentPolarion ModuleThe current Polarion document (module) object
$docPolarion ModuleAlias for $document, provides access to document API
$transactionTransactionCurrent Polarion transaction for data operations
$itemWork ItemCurrent 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

VariableTypeDescription
$repositoryServiceRepository ServiceAccess to Polarion repository operations for querying work items and documents
$securityServiceSecurity ServiceReturns the current user and role membership (top panel)
$testManagementServiceTest Management ServiceRetrieves 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.
diagram

Bridging Top Panel Functions to Formulas

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 ContextDescription
pdfExportMacros.vmHelper macros for PDF-specific formatting and layout
revision parameterRequired 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

ScenarioBehavior
Template rendering errorRed error message box displayed in place of the panel
Missing template fileDefault empty panel rendered
Velocity syntax errorError details rendered as HTML in the panel area
Last modified on July 10, 2026