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.
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 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:
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.
-
Add a page parameter named
baselineRevision of type string to your Gantt report page.
-
In Widget Parameters > Advanced > Item Script, add the baseline loading logic:
-
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