Service Summary
Variable Polarion Service Purpose $trackerServiceITrackerService Query work items, access project metadata, run Lucene searches $txServiceITransactionService Transaction management within templates $repositoryServiceIRepositoryService Access project metadata, users, roles, repository configuration $securityServiceISecurityService Check permissions, implement role-based visibility
$trackerService (ITrackerService)
Provides access to work item queries, project metadata, and tracker operations.
Method Return Type Description getWorkItemByUri(uri)IWorkItem Retrieve a work item by its Polarion URI getDataService()IDataService Access the Lucene query service for search operations getProject(projectId)IProject Access project metadata by ID
#set($related = $trackerService.getWorkItemByUri($item.uri))
Related: $related.title
Example: Run a Lucene Query
#set($ds = $trackerService.getDataService())
#set($results = $ds.searchInstances("WorkItem", "type:systemRequirement AND project.id:MyProject", "title", -1))
Found $results.size() items
Running Lucene queries inside server-rendered templates executes for every row in the sheet. Avoid complex queries in templates displayed on large datasets.
$txService (ITransactionService)
Provides access to Polarion’s transaction management within server-rendered expressions.
Method Return Type Description Transaction access Transaction Access to current transaction context
Example
Transaction service usage in server-rendered templates is primarily for understanding the execution context. Consult Polarion API documentation for available methods.
$repositoryService (IRepositoryService)
Provides access to project metadata, users, roles, and repository-level configuration.
Method Return Type Description getProjectById(id)IProject Access project by identifier getAllProjects()collection List all accessible projects
Example: Access Project Name
#set($proj = $repositoryService.getProjectById($item.projectId))
Project: $proj.name
Available methods depend on the Polarion server version. The repository service provides read-only access to repository-level resources.
$securityService (ISecurityService)
Enables permission checking, role-based visibility, and user authentication within templates.
Method Return Type Description getCurrentUser()IUser Returns the currently authenticated user canRead(object)boolean Check read permission for an object
Example: Conditional Content by User Role
#set($user = $securityService.getCurrentUser())
Evaluated by: $user.getId()
Example: Permission-Based Visibility
#if($securityService.canRead($item))
$item.title
#else
[Restricted]
#end
Service Caching
Aspect Detail Cache scope Services are cached in a static context at server startup Lifetime Services persist for the lifetime of the Polarion server process Thread safety Service instances are thread-safe and shared across all template evaluations Extension Per-evaluation variables ($item, $wi, $module, $context) are layered on top of the cached service context
Platform services ($trackerService, $txService, $repositoryService, $securityService) are shared across all evaluations. Entity-specific variables ($item, $wi, $module, $context) are set fresh for each work item evaluation.
Error Handling
If a service method call fails during template evaluation, the server renderer returns the #SERVER_RENDER_ERROR marker. Check the Polarion server logs for:
Exception Type Cause MethodInvocationException Service method threw an exception (e.g., permission denied, null argument) ParseErrorException Invalid Velocity syntax in the template ResourceNotFoundException Referenced resource does not exist
Complete YAML Example
domainModelTypes :
SystemRequirement :
polarionType : systemRequirement
properties :
title : ~
severity : ~
evaluatedBy :
serverRender : "$securityService.getCurrentUser().getId()"
projectName :
serverRender : |
#set($proj = $repositoryService.getProjectById($item.projectId))
$proj.name
linkedCount :
serverRender : |
#set($links = $wi.getLinkedWorkItems())
$links.size()
Sheet configuration:
columns :
id :
width : 80
title :
width : 300
evaluatedBy :
width : 150
formatter : readOnly
projectName :
width : 150
formatter : readOnly
linkedCount :
width : 80
formatter : readOnly
sources :
- id : requirements
title : System Requirements
model : rtm
query :
from : SystemRequirement
where : "<WHERE>"
Related Pages
Source context: ServerRenderer, ServerRendererTest, MetadataTest, model.yaml, DomainModelTypeV2
Source Code
prod-powersheet-src/com.nextedy.powersheet.client/src/modules/DocumentProvider/DocumentProvider.tsx
ServerRendererTest.java
MetadataTest.java
plugin.xml
prod-powersheet-src/com.nextedy.powersheet/src/com/nextedy/powersheet/PowersheetService.java