Skip to main content

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

  1. Open your Gantt page in Edit mode.
  2. In the widget parameter sidebar, expand the Advanced section.
  3. Locate the Item Script text area.
  4. Enter your JavaScript snippet.
  5. 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

The task object contains the following fields that you can read or modify:

Basic Example: Pass Assignee Names to the Client

This script reads all assignees from the work item and stores a comma-separated string in the 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 the task.hide property to hide specific work items from the chart:
Use task.hide in item scripts when you need conditional logic beyond what the widget query provides. For simple type filtering, configure the query directly in the widget parameters instead.

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.
If you upgraded to Polarion 2304 or later, existing item scripts may stop working. Key changes:
  • Use typeof wi !== 'undefined' instead of wi != null for null checks.
  • Use getter methods instead of direct property access: wi.getStatus().getId() instead of wi.status.id.
  • Use wi.getType().getId() instead of wi.type.id.
See Migrate Scripts for Polarion 2304+ for a full migration guide.

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

Last modified on July 10, 2026