Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

GlideTimelineItem- Global

The GlideTimelineItem API extends the abstract ScheduleItem class to define additional properties that are specific to the time line.

A time line item is essentially any item that displays in a singular row across the time line. A GlideTimelineItem has zero or more associated spans (TimelineSpan objects).

Parent Topic:Server API reference

GlideTimelineItem - GlideTimelineItem(String tableName)

Create a "dummy" GlideTimelineItem object.

This is useful for creating rows that do not allow any YMoving into; however, contain nested children (e.g. The top-level "Users" row in the Group Resource Timeline). The sys_idneeds to be unique for DOM level functions to parse correctly. By default this object will not be "droppable" because a table name was not specified.

NameTypeDescription
tableNameStringThe name of the table associated with current object.
TypeDescription
void 

GlideTimelineItem - GlideTimelineItem(String tableName, String sys_id)

Constructor that sets the required table and sys_idproperties.

The rest of this object's properties should be set by the caller. By default, this object instance is "droppable" since a table name is specified.

NameTypeDescription
tableNameStringThe name of the table associated with current object.
sys_idStringThe sys ID for the object.
TypeDescription
void 

GlideTimelineItem - createTimelineSpan(String tableName)

Creates a new TimelineSpan object associated with the current instance object.

If no other TimelineSpan objects exist, the newly created object will share the same sys_idas current instance object. Otherwise, a randomly generated GUID will be used.

NameTypeDescription
tableNameStringThe name of the table associated with current object.
TypeDescription
ObjectThe newly-created span object instance.

GlideTimelineItem - createTimelineSpan(String tableName, String sys_id)

Creates a new TimelineSpan object associated with the current instance object using the specified table and sys_id.

NameTypeDescription
tableNameStringName of the table associated with current object
sys_idStringSys_id for the object.
TypeDescription
ObjectNewly-created span object instance.

The following example shows how to use createTimelineSpan() to create a new TimelineSpan object.

var project_id="741cc7491b6f1c5043de32231b4bcbc5"; // Project ID 
var grUser = new GlideRecord('user_resource');
grUser.addQuery('planned_task', project_id);
grUser.setQueryReferences(true);
grUser.orderBy('user.name', 'DESC');
grUser.query();
while (grUser.next()) {
  var item = new GlideTimelineItem(grUser.getTableName(), grUser.user);
  /* Specify the text to display in the left pane for this item. */
  item.setLeftLabelText(grUser.user.name); 
  /* Set the name of the image file (including it's path) */
  item.setImage('../images/icons/user.gifx'); 
  /* Specify whether or not to bold the text style of the item in the left pane. */
  item.setTextBold(true); 
  /* Set whether or not the current instance object can be clicked and dragged into another GlideTimelineItem */
  item.setIsDraggable(true);
  /* Create a new TimelineSpan object associated with the current instance object using the specified table and sys_id. */ 
  item.createTimelineSpan(grUser.getTableName(), grUser.getUniqueValue());
}

GlideTimelineItem - getImage( )

Returns a string specifying the name of the image file associated with the current GlideTimelineItem.

NameTypeDescription
none  
TypeDescription
StringThe name of the image file associated with the current GlideTimelineItem. If no image is associated with the current item, an empty string ("") is returned.

GlideTimelineItem - getIsDroppable( )

Indicates whether or not the current instance object should be allowed as a "drop zone" when moving timeline elements vertically.

NameTypeDescription
none  
TypeDescription
BooleanTrue if droppable; false otherwise.

GlideTimelineItem - getLeftLabelText( )

Returns the text to be displayed in the left pane (if enabled).

NameTypeDescription
none  
TypeDescription
StringThe value of the text to be displayed in the left pane.

GlideTimelineItem - getParent( )

Returns the unique sysId of the current GlideTimelineItem's parent object.

NameTypeDescription
none  
TypeDescription
StringThe unique sysId of the current GlideTimelineItem's parent object. If the parent does not exist, this will return an empty string ("").

GlideTimelineItem - getTimelineSpans( )

Returns all the TimelineSpan objects associated with the current instance in an ArrayList.

NameTypeDescription
none  
TypeDescription
Object ArrayThe list of TimelineSpan objects associated with the current instance.

GlideTimelineItem - isTextBold( )

Indicates if the left pane text is set to display using a bold style.

NameTypeDescription
None  
TypeDescription
BooleanFlag that indicates whether the text should be bold.Possible values: - true: Text should be bold. - false: Text should not be bold.

The following example checks if an incident's state is "New" and sets the item text to bold.

var NewIncidentTimelineScriptInclude = Class.create();
NewIncidentTimelineScriptInclude.prototype = Object.extendsObject(AbstractTimelineSchedulePage, {

  getItems: function() {
    // Specify the page title 
    this.setPageTitle('New Incident Timeline');

    var groupNew = new GlideTimelineItem('new');
    groupNew.setLeftLabelText('New Incidents');

    groupNew.setImage('../images/icons/all.gifx');
    this.add(groupNew);

    // Get all the new incidents and add them to a new label 
    var grIncident = new GlideRecord('incident');
    grIncident.query();
    while (grIncident.next()) {
      // Loop through all and capture new incidents 
      if (grIncident.incident_state != '1') continue;

      // Create the item and the span item. 
      var item = new GlideTimelineItem(grIncident.getTableName(), grIncident.sys_id);
      var span = item.createTimelineSpan(grIncident.getTableName(), grIncident.sys_id);

      if (grIncident.incident_state == '1') { // New
        item.setParent(groupNew.getSysId());
        // Check and set bold text
          item.setTextBold(item.isTextBold() ? false : true);
        } 
      item.setImage('../images/icons/open.gifx');
      span.setTimeSpan(grIncident.getElement('opened_at').getGlideObject().getNumericValue(),
      grIncident.getElement('opened_at').getGlideObject().getNumericValue());

      // Show different colors based upon the priorities only for new incidents 
      switch (grIncident.getElement('priority').toString()) {
        case '1':
          span.setPointIconClass('red_circle');
          break;
        case '2':
          span.setPointIconClass('red_square');
          break;
        case '3':
          span.setPointIconClass('blue_circle');
          break;
        case '4':
          span.setPointIconClass('blue_square');
          break;
        case '5':
          span.setPointIconClass('sepia_circle');
          break;

          default: // Otherwise, the default point icon class will be used (Milestone)
      }

      // Common item properties 
      item.setLeftLabelText(grIncident.short_description);

      // Common span properties
      span.setSpanText(grIncident.short_description);
      span.setSpanColor('blue');
      span.setTooltip('<strong>' + GlideStringUtil.escapeHTML(grIncident.short_description) +
        '</strong><br>' + grIncident.number);
      this.add(item);
    }
  }

});

GlideTimelineItem - setImage(String strImageName)

Sets the name of the image file (including it's path) to use as the icon for the item in the left pane.

NameTypeDescription
strImageNameStringName of the image, including its path.
TypeDescription
void 

The following example shows how to use setImage() to define the image that should appear for the icon in the left pane.

var project_id="741cc7491b6f1c5043de32231b4bcbc5"; // Project ID 
var grUser = new GlideRecord('user_resource');
grUser.addQuery('planned_task', project_id);
grUser.setQueryReferences(true);
grUser.orderBy('user.name', 'DESC');
grUser.query();
while (grUser.next()) {
  var item = new GlideTimelineItem(grUser.getTableName(), grUser.user);
  /* Specify the text to display in the left pane for this item. */
  item.setLeftLabelText(grUser.user.name); 
  /* Set the name of the image file (including it's path) */
  item.setImage('../images/icons/user.gifx'); 
  /* Specify whether or not to bold the text style of the item in the left pane. */
  item.setTextBold(true); 
  /* Set whether or not the current instance object can be clicked and dragged into another GlideTimelineItem */
  item.setIsDraggable(true); 
}

GlideTimelineItem - setIsDraggable(Boolean b)

Sets whether or not the current instance object can be clicked and dragged into another GlideTimelineItem.

NameTypeDescription
bBooleanFlag that indicates whether the item can be moved using click and drag. Valid values: - true: Item can be moved using click and drag. - false: Item cannot be moved using click and drag.
TypeDescription
void 

The following example shows how to use setIsDraggable() to enable the current object to be dragged into another GlideTimelineItem.

var project_id="741cc7491b6f1c5043de32231b4bcbc5"; // Project ID 
var grUser = new GlideRecord('user_resource');
grUser.addQuery('planned_task', project_id);
grUser.setQueryReferences(true);
grUser.orderBy('user.name', 'DESC');
grUser.query();
while (grUser.next()) {
  var item = new GlideTimelineItem(grUser.getTableName(), grUser.user);
  /* Specify the text to display in the left pane for this item. */
  item.setLeftLabelText(grUser.user.name); 
  /* Set the name of the image file (including it's path) */
  item.setImage('../images/icons/user.gifx'); 
  /* Specify whether or not to bold the text style of the item in the left pane. */
  item.setTextBold(true); 
  /* Set whether or not the current instance object can be clicked and dragged into another GlideTimelineItem */
  item.setIsDraggable(true); 
}

GlideTimelineItem - setLeftLabelText(String strText)

Specifies the text to display in the left pane for this item.

NameTypeDescription
strTextStringText to display in the left pane for this item.
TypeDescription
void 

The following example shows how to use setLeftLabelText() to set the text in the left pane.

var project_id="741cc7491b6f1c5043de32231b4bcbc5"; // Project ID 
var grUser = new GlideRecord('user_resource');
grUser.addQuery('planned_task', project_id);
grUser.setQueryReferences(true);
grUser.orderBy('user.name', 'DESC');
grUser.query();
while (grUser.next()) {
  var item = new GlideTimelineItem(grUser.getTableName(), grUser.user);
  /* Specify the text to display in the left pane for this item. */
  item.setLeftLabelText(grUser.user.name); 
  /* Set the name of the image file (including it's path) */
  item.setImage('../images/icons/user.gifx'); 
  /* Specify whether or not to bold the text style of the item in the left pane. */
  item.setTextBold(true); 
  /* Set whether or not the current instance object can be clicked and dragged into another GlideTimelineItem */
  item.setIsDraggable(true); 
}

GlideTimelineItem - setParent(String sysId)

Sets the parent of the current GlideTimelineItem.

NameTypeDescription
sysIdStringThe sysID of the GlideTimelineItem that should become the parent of the current GlideTimelineItem.
TypeDescription
void 

GlideTimelineItem - setTextBold(Boolean b)

Specifies whether or not to bold the text style of the item in the left pane.

NameTypeDescription
bBooleanFlag that indicates whether the text in left pane should be bold.Valid values: - true: Text should be bold. - false: Text should not be bold.
TypeDescription
void 

The following example shows how to set the text in the left pane to bold.

var project_id="741cc7491b6f1c5043de32231b4bcbc5"; // Project ID 
var grUser = new GlideRecord('user_resource');
grUser.addQuery('planned_task', project_id);
grUser.setQueryReferences(true);
grUser.orderBy('user.name', 'DESC');
grUser.query();
while (grUser.next()) {
  var item = new GlideTimelineItem(grUser.getTableName(), grUser.user);
  /* Specify the text to display in the left pane for this item. */
  item.setLeftLabelText(grUser.user.name); 
  /* Set the name of the image file (including it's path) */
  item.setImage('../images/icons/user.gifx'); 
  /* Specify whether or not to bold the text style of the item in the left pane. */
  item.setTextBold(true); 
  /* Set whether or not the current instance object can be clicked and dragged into another GlideTimelineItem */
  item.setIsDraggable(true); 
}