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:
Additionally, Velocity pre-processing runs before script execution, making
$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:
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.