What Item Scripts Do
Item scripts run on the server for each work item loaded into the Gantt chart. They let you read data from the Polarion work item object (wi) and pass it to the client-side task object (task) using the task.getFields().put(KEY, VALUE) pattern.
Common use cases include extracting assignee names, computing custom labels, reading custom field values, and controlling task visibility.
Access the Item Script Parameter
- Open your Gantt page in Edit mode.
- In the widget parameter sidebar, expand the Advanced section.
- Locate the Item Script text area.
- Enter your JavaScript snippet.
- Click Apply.
Available Variables
Item scripts have access to the following server-side variables:| Variable | Type | Description |
|---|---|---|
task | Task | The Gantt task object being sent to the client |
wi | IWorkItem | The Polarion work item (read data from here) |
item | IWorkItem | Alias for wi |
plan | IPlan | The Polarion plan (Plans Gantt only) |
config | Config | The current Gantt configuration object |
ganttDataService | IGanttDataService | Server-side data service for advanced queries |
util | Utility | Helper methods (e.g., getDate, getDuration) |
$project and $user available as Velocity expressions within the script text.
Task Object Properties
Thetask object contains the following fields that you can read or modify:
| Field | Type | Description |
|---|---|---|
id | String | Unique task identifier |
text | String | Display label (work item ID + title) |
start_date | Date | Task start date |
duration | int | Task duration in days (default: 10) |
progress | float | Completion percentage (0.0 to 1.0) |
parent | String | Parent task ID |
type | String | Task type (task, project, milestone) |
url | String | Link to the Polarion work item |
itemId | String | Polarion work item ID (e.g., “WI-123”) |
projectId | String | Polarion project ID |
readonly | boolean | Whether the task is read-only |
unplanned | boolean | Whether the task has no scheduled dates |
open | boolean | Whether the task node is expanded |
color | String | CSS color for the task bar |
fields | Map | Custom key-value pairs passed to the client |
Basic Example: Pass Assignee Names to the Client
fields map under the key "assignees". You can then reference this value in Gantt Config Script templates (for example, to display it as right-side text on the task bar).
Control Task Visibility
Use thetask.hide property to hide specific work items from the chart:
Error Handling
Script errors are logged on the server but do not crash the Gantt chart load. When an item script contains an error, a warning indicator appears in the Gantt toolbar showing the error count. Hover over it to see the error details.Verification
After adding an item script, you should now see:- No error indicator in the Gantt toolbar (the script runs without errors).
- Custom field values available in the task data (verify by referencing them in a Gantt Config Script template or tooltip).
- Tasks hidden or modified according to your script logic.
See Also
- Write Gantt Config Scripts
- Write Page Scripts with Velocity
- Color Logic Script Examples
- Migrate Scripts for Polarion 2304+
- Debug Script Errors
- Compare Schedule with Baselines
Sources
Sources
KB ArticlesSupport TicketsSource Code
prod-gantt-src/com.nextedy.polarion.gantt.client/cypress/e2e/ganttCheckWarningInfo.cy.tsprod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/impl/ScriptEvaluator.javaprod-gantt-src/com.nextedy.polarion.gantt.client/src/js/nextedy.jsprod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/impl/GanttScriptTransformer.javaprod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/impl/AbstractBaseGanttDataService.java