Using Milestone Markers

Modified on Wed, 30 Jul at 5:22 PM

Milestone Markers help highlight key dates, such as version releases or planned launches. These markers appear as vertical lines in the Gantt widget, making it easy to spot critical events and helping you avoid missed deadlines. This article outlines several ways to display Milestone Markers - from manually adding them using a script, to automatically rendering them from Plans and Work Items, including options for dynamic customization.


Markers are defined via the Markers Script in the Advanced section in the Parameters.





TABLE OF CONTENTS



Manually adding a Milestone Marker

If you want to create a marker with values you define yourself (not derived from data), you can adjust the following script according to your needs and place it into the Markers Script section:


var marker = markerFactory.addMarker();
marker.setText("20.0");
marker.setDate("2025-08-04");
marker.setColor("green");


This example creates a green milestone marker labeled 20.0 for the date August 4, 2025:




Add markers from Plans or Work Items

Starting from version 23.5.3, you can automatically pull markers from Plans or Work Items in other projects using the following scripts:

markerFactory.addPlanMarkers("template.id:iteration AND project.id:gantt2","blue")

markerFactory.addWorkItemMarkers("type:release AND project.id:gantt2","start","red")

How the scripts work:

  • template.id:iteration - fliters only Plan items with the specified template ID
  • type:release - filters WIs of a specific Type
  • project.id:gantt2 - defines the source project
  • start - specifies which date field should be used to render the marker; this needs to be determined


Example: We retrieved release-type items from the project Gantt2. In this case, the marker date is taken from the custom field Public Launch:


Used script:

markerFactory.addWorkItemMarkers("type:release AND project.id:gantt2","publicLaunch","blue")




In the screenshot below, you can see that the due date for marker Version 3.0 is set from the field Public Launch to 2025-06-02:






Use Polarion API for dynamic markers

Using the Polarion Open API allows you to dynamically generate milestone markers based on Polarion data. You can retrieve data stored in your project, such as Time Points, Plans, or specific types of Work Items. This method is useful when:

  • You need to render a large number of markers based on live data
  • You want to filter which markers appear based on conditions (e.g., specific types or fields)
  • You want to customize visual aspects like marker color or tooltip content based on data values


Unlike marker methods addPlanMarkers and addWorkItemMarkers, which follow a fixed structure, this approach gives you full scripting control using the trackerService and markerFactory APIs.

The markerFactory has the following methods:

  • markerFactory.addMarker(); - create and register a new marker object
  • markerFactory.addMarker(String text, String title); - utility method if you do not have a date as java.util.Date, but as a string

           Example: markerFactory.addMarker("test","2019-01-30")



The marker object provides the following methods:

  • void setText(String text) - set the text/name of the marker
  • void setTitle(String tooltip) - set the tooltip of the marker
  • void setDate(java.util.Date date) - set the date of the marker
  • void setDate(String dateStr) - set the date of the marker as a String

           Date format is "2019-01-30"



Example: Loading Time Points:

var timePoints = trackerService.getTrackerProject("GANTT").getTimePoints().iterator();
while(timePoints.hasNext()){
    var tp = timePoints.next();
    var marker = markerFactory.addMarker();
    marker.setText(tp.getName());
    marker.setDate(tp.getTime().getDate());
    marker.setColor("fuchsia");
    var desc =  tp.getDescription();
    if(desc!=null){
        marker.setTitle(desc.getContent());
    }
}


Used Time Points:



Below, we can see the derived Time Points in our Gantt project:




Polarion 22 R2 and older

For older versions of Polarion, use the legacy API format as follows:

var timePoints = trackerService.getTrackerProject("GANTT").getTimePoints().iterator();
while(timePoints.hasNext()){
    var tp = timePoints.next();
    var marker = markerFactory.addMarker();
    marker.setText(tp.name);
    marker.setDate(tp.time.date);
    marker.setColor("fuchsia");
    var desc =  tp.description;
    if(desc!=null){
        marker.setTitle(desc.content);
    }
}



Dynamic marker customization

The method of using trackerService also allows you to control which WIs are displayed as milestone markers using Page Parameters and Field Values


This method:

  • reads a page parameter
  • converts it into a search query 
  • fetches matching Work Items
  • renders them as markers using a date and style from their fields


This enables you to quickly change which markers are displayed by simply adjusting the Page Parameter.


Example:

var milestoneIds =  config.pageParameters.milestone;
if(milestoneIds===null){
  milestoneIds="";
}else{
   milestoneIds=milestoneIds.replaceAll(',',' ');
}

var milestones = trackerService.queryWorkItems("project.id:Gantt3 AND type:milestone AND id:(" +milestoneIds +")","id").iterator();

while(milestones.hasNext()){
    var tp = milestones.next();
    var marker = markerFactory.addMarker();
    marker.setText(tp.getTitle());
    marker.setDate(tp.getValue('releaseDate').getDate());
    var productType = tp.getValue('productType');
    marker.setColor("blue");

    if (productType!==null && productType.getId()==='typeB'){
        marker.setColor("fuchsia");
    }

}


In this example, we work with Milestone-type WIs located in the project Gantt3. We use two Custom Fields relevant to our milestone items: 

  • 'releaseDate' - stores a date
  • 'productType' - an enumeration field with values such as typeA, typeB, and typeC:





We want to display these WIs as Milestone Markers with some additional customization:

  • The marker's date should be taken from the 'releaseDate' field
  • By default, the marker's color should be blue if the 'productType' field has a value
  • If the value of 'productType' is typeB, the marker should be pink (fuchsia)


Additionally, we don't want to show all Milestone-type items from the Gantt3 project - only specific ones. To achieve this, we'll use a Page Parameter, which you can configure in Edit mode. For this example, we'll create an Enumeration-type Page Parameter, because we want to display a dropdown menu with Milestone WIs. The parameter ID must match the one used in the script, so we name it 'milestone':




As a result, Gantt displays only selected items as Milestone Markers. The date is taken from the 'releaseDate' field. Markers for Milestones 1 and 3 appear blue (since 'productType' has a value), while Milestone 2 is pink because its 'productType' is typeB:







To quickly change displayed markers, we can add a Page Parameters Block widget to the page where we have the Gantt widget. We added our 'milestone' parameter here:




Finished Gantt:





Marker Tooltip 

In version 25.1.0 and later, markers created with:

    • markerFactory.addPlanMarkers(...)

    • markerFactory.addWorkItemMarkers(...)

will automatically display a tooltip with marker details, such as title and due date.


For custom markers, you can define a tooltip manually:

marker.setTitle("Tooltip text here");

This is useful if you're generating markers from an API or dynamic data sources and want to show more context on hover.





Positioning markers at the end of the day

By default:

  • Markers added via addPlanMarkers or addWorkItemMarkers are positioned at the end of the day.
  • Manually created markers (via addMarker) appear at the exact time.


To push manual markers to the end of the day, use:

marker.pushByDay();

This ensures your marker is displayed at the end of the specified day instead of the start.



For any assistance, please don’t hesitate to reach out by submitting a ticket here.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article