Skip to main content

How Page Scripts Work

Page scripts run on the Polarion server using the Apache Velocity template engine. The rendered output is then embedded into the Gantt widget as JavaScript. This means you can use Velocity expressions to access Polarion data (projects, users, plans, work items) and inject dynamic values into the Gantt configuration.
diagram
A common use is a page script that reads a page parameter (for example a department parameter) and injects it into the widget’s query so the Gantt shows only the matching work items:
A 'department' Page Parameter referenced in the Gantt widget Query field to filter which work packages are shown
Selecting a department value for the Page Parameter that the query field uses to filter the Gantt
A page script can also walk up the parent hierarchy and add the parents of the selected items to the chart, using $pageContext to pass the assembled query back to the widget’s Query field:
Velocity page script iterating two parent levels and writing the assembled parentQ value into the Query field so parent items appear on the Gantt

Available Velocity Context Variables

The following objects are available inside page scripts:

Create a Baseline Comparison Page

This example creates a portal page that lists project baselines and opens the Gantt chart with a comparison overlay.
  1. Add a page parameter named baselineRevision of type string to your Gantt report page.
  2. In Widget Parameters > Advanced > Item Script, add the baseline loading logic:
  3. Create a separate Wiki page with this Velocity snippet to list baselines:
The field names in util.getDate(origWi, "start") and util.getDuration(origWi, "initialEstimate") must match the field names in your widget Data Mapping section. If you use plannedStart and duration, update the script accordingly.

Add Dynamic Markers with Velocity

Use the markerFactory in the Markers Script to create timeline markers from Polarion data. For example, load iteration boundaries from plans:
Or load project time points using the Polarion API:
If you are on Polarion 2304 or later, use getter methods like tp.getName() and tp.getTime().getDate() instead of direct property access like tp.name and tp.time.date. See Migrate Scripts for Polarion 2304+ for details.

Verify Your Changes

After saving the page, reload the Gantt chart. You should now see:
  • Baseline comparison bars rendered below current task bars (if a baseline revision is selected)
  • Dynamic markers appearing as vertical lines on the Gantt timeline
  • Velocity-generated values correctly resolved in the widget output

See Also

Last modified on July 10, 2026