Skip to main content

Service Summary

VariablePolarion ServicePurpose
$trackerServiceITrackerServiceQuery work items, access project metadata, run Lucene searches
$txServiceITransactionServiceTransaction management within templates
$repositoryServiceIRepositoryServiceAccess project metadata, users, roles, repository configuration
$securityServiceISecurityServiceCheck permissions, implement role-based visibility
diagram

$trackerService (ITrackerService)

Provides access to work item queries, project metadata, and tracker operations.
MethodReturn TypeDescription
getWorkItemByUri(uri)IWorkItemRetrieve a work item by its Polarion URI
getDataService()IDataServiceAccess the Lucene query service for search operations
getProject(projectId)IProjectAccess 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.
MethodReturn TypeDescription
Transaction accessTransactionAccess to current transaction context

Example

$txService
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.
MethodReturn TypeDescription
getProjectById(id)IProjectAccess project by identifier
getAllProjects()collectionList 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.
MethodReturn TypeDescription
getCurrentUser()IUserReturns the currently authenticated user
canRead(object)booleanCheck 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

AspectDetail
Cache scopeServices are cached in a static context at server startup
LifetimeServices persist for the lifetime of the Polarion server process
Thread safetyService instances are thread-safe and shared across all template evaluations
ExtensionPer-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 TypeCause
MethodInvocationExceptionService method threw an exception (e.g., permission denied, null argument)
ParseErrorExceptionInvalid Velocity syntax in the template
ResourceNotFoundExceptionReferenced 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>"

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