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).

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_id needs 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.

Table 1. Parameters
Name Type Description
tableName String The name of the table associated with current object.
Table 2. Returns
Type Description
void

GlideTimelineItem - GlideTimelineItem(String tableName, String sys_id)

Constructor that sets the required table and sys_id properties.

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.

Table 3. Parameters
Name Type Description
tableName String The name of the table associated with current object.
sys_id String The sys ID for the object.
Table 4. Returns
Type Description
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_id as current instance object. Otherwise, a randomly generated GUID will be used.

Table 5. Parameters
Name Type Description
tableName String The name of the table associated with current object.
Table 6. Returns
Type Description
Object The 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.

Table 7. Parameters
Name Type Description
tableName String Name of the table associated with current object
sys_id String Sys_id for the object.
Table 8. Returns
Type Description
Object Newly-created span object instance.

Example

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.

Table 9. Parameters
Name Type Description
none
Table 10. Returns
Type Description
String The 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.

Table 11. Parameters
Name Type Description
none
Table 12. Returns
Type Description
Boolean True if droppable; false otherwise.

GlideTimelineItem - getLeftLabelText( )

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

Table 13. Parameters
Name Type Description
none
Table 14. Returns
Type Description
String The value of the text to be displayed in the left pane.

GlideTimelineItem - getParent( )

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

Table 15. Parameters
Name Type Description
none
Table 16. Returns
Type Description
String The 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.

Table 17. Parameters
Name Type Description
none
Table 18. Returns
Type Description
Object Array The 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.

Table 19. Parameters
Name Type Description
None
Table 20. Returns
Type Description
Boolean Flag that indicates whether the text should be bold.
Possible values:
  • true: Text should be bold.
  • false: Text should not be bold.

Example

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.

Table 21. Parameters
Name Type Description
strImageName String Name of the image, including its path.
Table 22. Returns
Type Description
void

Example

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.

Table 23. Parameters
Name Type Description
b Boolean Flag 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.
Table 24. Returns
Type Description
void

Example

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.

Table 25. Parameters
Name Type Description
strText String Text to display in the left pane for this item.
Table 26. Returns
Type Description
void

Example

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.

Table 27. Parameters
Name Type Description
sysId String The sysID of the GlideTimelineItem that should become the parent of the current GlideTimelineItem.
Table 28. Returns
Type Description
void

GlideTimelineItem - setTextBold(Boolean b)

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

Table 29. Parameters
Name Type Description
b Boolean Flag that indicates whether the text in left pane should be bold.
Valid values:
  • true: Text should be bold.
  • false: Text should not be bold.
Table 30. Returns
Type Description
void

Example

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); 
}