Script Variables
The following variables are available in the Item Script scope:| Variable | Type | Description |
|---|---|---|
task | Task object | The Gantt task being prepared for client rendering. Modify its properties to change appearance and behavior. |
wi | IWorkItem | The source Polarion work item. Read work item fields, status, type, assignees, and linked items. |
plan | IPlan | The source Polarion plan (Plans Gantt only). Access plan dates, template ID, and contained work items. |
trackerService | ITrackerService | Polarion tracker service for querying work items via Lucene queries. |
config | Configuration object | The current Gantt configuration, including page parameters. |
util | Utility helper | Helper methods for date conversion and plan schedule derivation. |
Task Object Properties
Thetask object represents a Gantt chart task. You can read and modify these properties:
| Property | Type | Default | Description |
|---|---|---|---|
task.id | String | from work item | Unique task identifier derived from the Polarion work item ID. |
task.text | String | from work item | Display label combining the work item ID and title. |
task.start_date | Date | from configured field | Task start date. Set to override the configured start field value. |
task.duration | Integer | 10 | Task duration in days (or hours in high-precision mode). |
task.progress | Float | from configured field | Completion percentage as a decimal (0.0 to 1.0). |
task.parent | String | from parent link | ID of the parent task in the hierarchy. |
task.type | String | from configuration | Gantt task type: task (normal bar), project (summary bar derived from children), or milestone (diamond shape, zero duration). |
task.color | String | null | Static CSS color for the task bar. Overrides all dynamic coloring including progress-based colors. |
task.taskColor | String | null | Dynamic CSS color for the task bar. Only overrides the default blue color; does not affect progress-based colors (red, orange, gray). |
task.itemId | String | from work item | Polarion work item ID (e.g., WI-123). |
task.projectId | String | from work item | Polarion project ID containing the work item. |
task.readonly | Boolean | false | When true, prevents the task from being dragged or resized. |
task.unplanned | Boolean | false | When true, marks the task as unplanned (no scheduled dates). |
task.url | String | generated | URL to the Polarion work item. |
Custom Fields Map
Pass additional data to the client usingtask.getFields():
Color Logic
There are two color properties with different behavior:| Property | Behavior | Use Case |
|---|---|---|
task.color | Static — overrides ALL colors, including progress-based coloring | Force a specific color regardless of task status |
task.taskColor | Dynamic — only overrides the default blue color | Change color while preserving red/orange/gray progress indicators |
Color by Assignee Example
Color by Type and Status Example
Progress Calculation
Compute progress from time estimates:Milestone Configuration
Set a task to render as a milestone diamond:Schedule Derivation from Plans
Derive a task’s schedule from its Polarion plan assignment:Baseline Comparison
Set custom baseline values for schedule comparison:Passing Data to Right-Side Text
Prepare data in the Item Script, then render it in the Gantt Config Script: Item Script:Script Execution Flow
Error Handling
- Script errors display as a warning indicator in the Gantt chart toolbar
- The error message includes the prefix Item Script Error:
- Add null checks before accessing work item properties:
if (wi != null) { ... } - On Polarion 2304+, use
typeof wi !== 'undefined'for existence checks
Configuration Example
A complete Item Script combining progress calculation, color logic, and right-side text:Related Pages
- Gantt Config Script API — client-side script for templates and events
- Velocity Context Variables — server-side variables available in script pre-processing
- Item Color Legend — default color behavior and how scripts override it
- Page Parameters API — access user-input parameters in scripts
- Marker Factory API — add milestone markers from scripts
Sources
Sources
KB Articles
- API Example: Color Logic
- API Example: Compute Plan Progress for Plans GANTT on the Server Using API
- Calculate Epic Progress
- Calculate item progress from time estimates
- Customised Working Hours per Resource
prod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/IGanttDataService.javaprod-gantt-src/com.nextedy.polarion.gantt.client/src/types/gantt-extended.d.tsprod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/Data.javaprod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/WorkItemsAccess.javaprod-gantt-src/com.nextedy.polarion.gantt.client/cypress/support/Taskline.ts