Skip to main content
diagram

Template Files

Template Resolution Properties

Templates are loaded from document attachments with fallback to the template hierarchy. The resolution mechanism tracks where the configuration was found using these properties:
diagram
Define templates once at the template document level. All documents created from that template inherit the Velocity templates automatically. Override individual templates by attaching a file with the same name directly to a specific document.

Velocity Context Variables

All Risksheet Velocity templates receive a context containing Polarion services, document objects, and utility tools. The available context variables depend on the template type.

Common Context (All Templates)

Top Panel Template Context (risksheetTopPanel.vm)

The top panel template renders at the /api/panel endpoint and has full access to the common Velocity context plus: Errors in the top panel template render as a red error message box in place of the panel content, displaying the exception details.

PDF Export Template Context (risksheetPdfExport.vm)

The PDF export template renders at the /api/pdfscript endpoint and includes additional context: See PDF Export Template for detailed template structure and macro reference.

Velocity Syntax Reference

Variables and Properties

Directives

Embedding JavaScript in Velocity

A key pattern in Risksheet templates is bridging server-side Polarion data to client-side JavaScript logic. The Velocity template executes on the server and generates HTML/JavaScript that runs in the browser:
When embedding Velocity variables into JavaScript strings, ensure the variable values do not contain characters that would break JavaScript syntax (quotes, backslashes, newlines). Use $esc.javascript($value) if the Velocity EscapeTool is available, or validate that custom field values contain only safe characters.

PDF Export Configuration Properties

The PDF export configuration service manages loading of the risksheetPdfExport.vm template:

Project Template Installation

Risksheet ships with predefined project templates that can be installed via the administration interface:

Installation Properties

Re-installing templates overwrites previous versions completely. The system removes old template data before uploading new versions to ensure a clean state. Back up any customizations made to installed templates before re-running setup.

Runtime Configuration Properties

When templates are loaded at runtime, the application exposes version and configuration metadata through the window context:

Error Handling

When a Velocity template error occurs, the error message is rendered directly in the panel or export output. Check the Polarion server logs for the full stack trace. Common causes include misconfigured risksheetTopPanel.vm files and references to document custom fields that do not exist.

Complete Example

A top panel template that extracts a document custom field and registers a queryFactory function for filtering linked items by product family:
This pattern demonstrates:
  1. Accessing document custom fields with $doc.getOldApi().getValue()
  2. Rendering server-side data into HTML for display
  3. Passing server-side values to client-side JavaScript variables
  4. Registering a queryFactory function that uses document-level context to filter which items are available for linking in Risksheet columns
A column references the registered factory by name through its typeProperties.queryFactory property in the sheet configuration:

See Also

Last modified on July 10, 2026