Skip to main content

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:
$item.title
$item.status
$item.author
$item.created
$item.updated
Example serverRender expression that combines fields:
properties:
  summary:
    serverRender: "$item.id: $item.title ($item.status)"
    readable: true
    updatable: false

Step 2: Use Conditional Logic

Velocity supports #if, #elseif, #else, and #end directives for conditional rendering:
properties:
  priorityLabel:
    serverRender: "#if($item.priority == 'critical')CRITICAL#elseif($item.priority == 'high')High#else Normal#end"
    readable: true
    updatable: false
DirectivePurpose
#if(condition)Start conditional block
#elseif(condition)Alternative condition
#elseDefault fallback
#endClose 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:
properties:
  docContext:
    serverRender: "$module.moduleFolder/$module.moduleName"
    readable: true
    updatable: false
If the entity is not associated with a document, $module will be null. Always add a null check: #if($module)$module.moduleName#else N/A#end

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:
properties:
  linkedCount:
    serverRender: "$wi.getLinkedWorkItemsStructsDirect().size()"
    readable: true
    updatable: false
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:
properties:
  projectName:
    serverRender: "$trackerService.getProjectById($item.projectId).getName()"
    readable: true
    updatable: false
Available service variables:
VariableServiceCommon Uses
$trackerServiceWork item trackerQuery work items, access projects
$txServiceTransactionTransaction context
$repositoryServiceRepositoryProject metadata, users, roles
$securityServiceSecurityPermission checks, user auth
See Access Polarion Services for detailed examples of each service.

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:
properties:
  safeTitle:
    serverRender: "#if($item && $item.title)$item.title#else (untitled)#end"
    readable: true
    updatable: false
If you see #SERVER_RENDER_ERROR in a column cell, the template failed due to a parse error, method invocation error, or missing resource. Check the Polarion server logs for the specific exception type.

Template Patterns Reference

String concatenation:
$item.id - $item.title
Null-safe access:
#if($item.severity)$item.severity#else Unset#end
Collection iteration:
#foreach($link in $wi.getLinkedWorkItemsStructsDirect())$link.getLinkedItem().getId() #end
Variable assignment:
#set($count = $wi.getLinkedWorkItemsStructsDirect().size())$count linked items
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:
  1. Open the powersheet document in Polarion
  2. You should now see computed values in the server-rendered column
  3. Verify that null-safe checks work by testing with work items that have empty fields
  4. If values show #SERVER_RENDER_ERROR, consult the Debug Template Errors guide

See Also

Source Code
  • MetadataTest.java
  • ServerRenderer.java
  • QueryDataTest.java
  • Property.java
  • ServerRendererTest.java