Skip to main content
diagram

Context Availability

TemplateVelocity Context AvailableNotes
risksheetTopPanel.vmYesFull context with Polarion services, document, and Velocity tools
risksheetPdfExport.vmYesFull context plus pdfExportMacros.vm helpers
risksheet.jsonYes (since 25.4.0)Velocity expressions evaluated during configuration parsing
Since version 25.4.0, Velocity context is available in risksheet.json. This enables dynamic configuration values using Polarion services like $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

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
The complete list of Polarion services available in the Velocity context depends on your Polarion version and Risksheet configuration. Verify available services in your deployment.
## Example: Query work items using repositoryService
#set($items = $repositoryService.getProjectService().getProject("myProject"))

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

Functions defined in the top panel <script> section can be called from risksheet.json formulas.
## 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.

Configuration Context (risksheet.json)

Since version 25.4.0, Velocity expressions in risksheet.json 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 risksheet.json 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
KB ArticlesSupport TicketsSource Code
  • RisksheetViewServlet.java
  • AppConfig.ts
  • PdfExportConfigurationService.java
  • AppConfigParser.ts