Service Injection Architecture
The static context is built once and stored in a cached base context object. All platform service references are then reused across every template evaluation without re-initialization, which keeps rendering fast even for large sheets.
Service Summary
$trackerService
Provides access to work item queries, project-level tracker metadata, and Lucene search operations. This is the most commonly used platform service in server-rendered properties because it enables cross-item lookups and data aggregation across the project.
Common Operations
Example: Retrieve a Work Item by URI
Example: Run a Lucene Query
Example: Access Project Metadata
Example: Count Linked Design Requirements
This pattern queries for all design requirements linked to the current work item:$txService
Provides access to Polarion transaction management. In the context of server-rendered properties, templates execute within a read-only evaluation context. The transaction service is primarily useful for understanding the execution context rather than performing write operations.
The
$txService variable is available in all templates. Its available methods depend on the Polarion server version. Consult the Polarion API documentation for the ITransactionService interface. Server-rendered expressions should not use this service to initiate write transactions — they run in a read-only evaluation context.$repositoryService
Provides access to repository-level operations: project metadata, user information, roles, and repository configuration. Useful for templates that need to display data from outside the current work item’s project scope or that need to resolve user or role information.
Example: Access Project Name
Example: Resolve a User ID to Display Name
Available methods depend on the Polarion server version. The repository service provides read-only access to repository-level resources. Consult the Polarion API documentation for
IRepositoryService.$securityService
Enables permission checking, role-based visibility, and user identification within templates. Use this service to conditionally render content based on the logged-in user’s identity or to verify access rights before displaying sensitive data.
Example: Show Current User
Example: Permission-Based Visibility
Example: Role-Based Content
Per-Item Context Variables
In addition to the static platform services, the server renderer injects per-item variables for each work item during evaluation. These are documented in detail on the Context Variables page. The summary:Prefer
$item (ModelObject) for accessing standard work item properties. Use $wi (IWorkItem) only when you need methods not available on $item, such as getCustomField() or getLinkedWorkItems(). The $wi variable is only set for work item entities — it is null for non-work-item entity types.Caching Behavior
Error Handling
When a Velocity template evaluation fails, the server renderer returns the constant error marker:serverRender expression for that property contains an error. Check the Polarion server logs for one of these exceptions:
Data Model Configuration
Server-rendered properties are configured in the data model YAML using theserverRender key on a property definition. The value is an Apache Velocity template that is evaluated for each work item when the sheet loads.
Property Definition
Properties with
serverRender are automatically marked as read-only — the computed value cannot be edited by users.
Single-Line Expression
Multi-Line Template
Use YAML block scalar syntax (|) for templates with conditional logic or multiple statements:
Complete YAML Example
The following data model and sheet configuration demonstrate all four platform services used in server-rendered properties within a standard RTM entity type. Data model YAML:Server-rendered properties are always read-only in the sheet. The
serverRender value is computed on each query and cannot be edited by the user. Mark the corresponding sheet columns with isReadOnly: true to communicate this in the UI.Best Practices
Service Availability Quick Reference
Use the following decision table to determine which service fits your use case:Related Pages
- Velocity Templates — template syntax and evaluation flow
- Context Variables — per-item context variables (
$item,$wi,$module,$context,$tx) - Properties — data model property definitions
- Permissions — entity-level security settings