The top panel template has full access to the document context and Polarion APIs:
Variable
Type
Purpose
Example
$document
Document
Current document object
$!document.customFields.item
$doc
RisksheetPolarionServiceImpl
Wrapped document with Polarion services
Enhanced API access
$documentId
String
Full document identifier
"PROJ-DOC/MyRisksheet"
$projectId
String
Project containing the document
"MYPROJECT"
$tx
ReadOnlyTransaction
Read-only transaction context
Query Polarion data
$trackerService
ITrackerService
Work item and project access
$trackerService.getProject()
$repositoryService
IRepositoryService
File and repository access
Load external config files
$securityService
ISecurityService
Permission and authentication
Check user access
The top panel operates in read-only mode. While you can query and display data, you cannot modify work items or Polarion objects directly. Use data transformation and conditional logic within the template.
## Show different content based on document status#set($status = $!document.customFields.status)#if($status == "Draft") <div class="rs-alert-warning"> ⚠️ This document is in draft status. Changes are not final. </div>#elseif($status == "InReview") <div class="rs-alert-info"> ℹ️ This document is awaiting approval review. </div>#elseif($status == "Published") <div class="rs-alert-success"> ✓ This document is published and active. </div>#end
## Show controls only to authorized users#set($user = $securityService.getCurrentUser())#set($isAdmin = $securityService.hasPermission($user, "ADMIN"))#if($isAdmin) <div class="admin-controls"> <button>Edit Configuration</button> <button>Reset to Template</button> </div>#end
## Access enum properties and transform them#set($severityEnum = $!document.customFields.severity)## Safely display enum with fallback#if($severityEnum) Severity: $!severityEnum#else Severity: <em>Not set</em>#end
For complex transformations, break the logic into multiple #set() statements within the template. Prepare all computed values before rendering, then output the final results. This pattern avoids confusion about what data is available at render time.
<div class="action-buttons"> <button onclick="openDocument('MYPROJ-DOC/RelatedRisksheet')">View Related Risksheet</button> <button onclick="exportPdf()">Export as PDF</button></div>
## Load related work items to display in top panel#set($project = $trackerService.getProject($projectId))#set($relatedDocId = $!document.customFields.relatedDoc)#if($relatedDocId) ## Attempt to retrieve related document #set($relatedDoc = $trackerService.getWorkItem($projectId, $relatedDocId)) #if($relatedDoc) <div class="related-info"> Related: $!relatedDoc.getTitle() </div> #end#end