Prerequisites
- A domain model with a server-rendered property (see Create a Computed Property)
- Basic understanding of Apache Velocity template syntax
Step 1: Access Work Item Properties via $item
The$item variable provides access to the work item model object. Use it to read standard and custom field values:
serverRender expression that combines fields:
Step 2: Use Conditional Logic
Velocity supports#if, #elseif, #else, and #end directives for conditional rendering:
| Directive | Purpose |
|---|---|
#if(condition) | Start conditional block |
#elseif(condition) | Alternative condition |
#else | Default fallback |
#end | Close block |
#foreach($x in $list) | Iterate over collections |
#set($var = value) | Assign a variable |
Step 3: Access Document Context via $module
When a work item belongs to a LiveDoc, the$module variable provides document-level properties:
Step 4: Use the Low-Level Work Item API via $wi
The$wi variable exposes the Polarion work item API for operations not available on $item:
The
$wi variable is only available for work item entities. For other entity types (documents, chapters), use $item or $module instead.Step 5: Use Platform Services
Server-rendered templates have access to several Polarion platform services:| Variable | Service | Common Uses |
|---|---|---|
$trackerService | Work item tracker | Query work items, access projects |
$txService | Transaction | Transaction context |
$repositoryService | Repository | Project metadata, users, roles |
$securityService | Security | Permission checks, user auth |
Step 6: Handle Errors Gracefully
When a Velocity template fails, Powersheet returns the error marker#SERVER_RENDER_ERROR in the cell. Protect against common failures with defensive coding:
Template Patterns Reference
String concatenation:The available methods on
$item, $wi, and platform services depend on your Polarion version. Test templates with simple expressions before building complex logic.Verify
After configuring a Velocity template expression:- Open the powersheet document in Polarion
- You should now see computed values in the server-rendered column
- Verify that null-safe checks work by testing with work items that have empty fields
- If values show
#SERVER_RENDER_ERROR, consult the Debug Template Errors guide
See Also
- Create a Computed Property — setting up server-rendered properties
- Access Polarion Services — using platform services in templates
- Debug Template Errors — troubleshooting template failures
- Configure a Formatter — styling computed values
Sources
Sources
Source Code
MetadataTest.javaServerRenderer.javaQueryDataTest.javaProperty.javaServerRendererTest.java