The AbstractTimelineSchedulePage script include is a helper class to facilitate working with the data displayed on timelines.

Processing the data displayed within a timeline starts by executing the corresponding function of the specified script include. Like other script includes, the language syntax is JavaScript and follows the default security constraints of this type of resource. However, because the different types of display options are complex, a helper class was created. To display a timeline, extend the AbstractTimelineSchedulePage class and pair it with it's corresponding schedule page. At a minimum, extending classes should override the getItems() method, as this is the primary event handler for returning items to be displayed on the client.

The client processes the data that AbstractTimelineSchedulePage returns in two phases. The first phase makes the actual updates to the timeline. Immediately after, if configured, the second phase displays a success message box, error message box, or dialog message prompt. In phase one, the available options for manipulating data include:

  • Do Not Update Any Items: This is the default behavior. Do not perform any of the remaining steps in phase one.
  • Update With Specific Items: This is done using: add().
  • Render The Timeline Using the getItems() Function: This is done using: setDoReRenderTimeline(true).
Note: If both TimelineItems are returned and setDoReRenderTimeline is set to true, the system ignores the setDoReRenderTimeline property and explicitly shows only the TimelineItems that were added by the add() function.

The available options in phase two include:

  • Do Not Display Any Message Boxes: This is the default behavior.
  • Display a Success Dialog Box: This is done using: setStatusSuccess().
  • Display an Error Dialog Box: This is done using: setStatusError().
  • Display a Dialog Confirm Box: This is done using: setStatusPrompt().
Note:

A script include class that extends AbstractTimelineSchedulePage automatically receives all URI parameters from the original URL whose prefix begins with sysparm_timeline_. To access the values of these, use: this.getParameter("sysparm_timeline_VARIABLE"); inside your extended class.

This is useful if you need to display a schedule page from a dynamic element, such as from a context menu from a list. By passing in dynamic data via the URL the schedule page auto-includes these parameters inside the Ajax calls and therefore will be accessible inside the AbstractTimelineSchedulePage script include.

AbstractTimelineSchedulePage - add(Object ObjTimeline)

Adds a TimelineItem object that will be returned to the client and appropriately displayed on the timeline.

Table 1. Parameters
Name Type Description
ObjTimeline Object The TimelineItem object to add to the timeline.
Table 2. Returns
Type Description
void

AbstractTimelineSchedulePage - addSeparator()

Adds a horizontal frame separator into the list of timeline items. All future items added via add() will be added into the subsequent timeline frame.

All future items added using the add() method are added into the subsequent timeline frame.

Table 3. Parameters
Name Type Description
None
Table 4. Returns
Type Description
void

Example

The following code example shows how to call this method.

// Inside of a script include that extends AbstractTimelineSchedulePage
      this.addSeparator();
    

AbstractTimelineSchedulePage - elementMoveX(String spanSysId, String newStartDateTimeMs)

Event handler for when a timeline span moves horizontally.

Table 5. Parameters
Name Type Description
spanSysId String The sys ID of the current span being adjusted.
newStartDateTimeMs String The new start time of the span in milliseconds. Make sure to parse the string using parseInt() before performing any numerical comparisons.
Table 6. Returns
Type Description
void

AbstractTimelineSchedulePage - elementMoveXY(String spanSysId, String itemSysId, String itemSysId, String newItemSysId, String newStartDateTimeMs)

Event handler for when a timeline span moves both horizontally and vertically.

Table 8. Returns
Type Description
void

AbstractTimelineSchedulePage - elementMoveY(String spanSysId, String itemSysId, String newItemSysId)

Event handler for when a timeline span moves vertically.

Table 9. Parameters
Name Type Description
spanSysId String The sys ID of the current span being adjusted.
itemSysId String The sys ID of the timeline item associated with the current span.
newItemSysId String The sys ID of the timeline item (a row) that the current span was dragged into.
Table 10. Returns
Type Description
void

AbstractTimelineSchedulePage - elementSuccessor(String spanSysId, String newSuccSpanId)

Event handler for when a timeline relationship has been created between two spans.

Table 11. Parameters
Name Type Description
spanSysId String The sys ID of the current span which will be a predecessor for the newly created relationship.
newSuccSpanId String The sys ID of the successor span from the relationship created.
Table 12. Returns
Type Description
void ReturnValue

AbstractTimelineSchedulePage - elementTimeAdjustEnd(String spanSysId, String newEndDateTimeMs)

Event handler for when a timeline span's end date was modified.

Table 13. Parameters
Name Type Description
spanSysId String The sys ID of the current span that is being adjusted.
newEndDateTimeMs String The new end time of the span in milliseconds. Make sure to parse the string using parseInt() prior to performing any numerical comparisons.
Table 14. Returns
Type Description
void

AbstractTimelineSchedulePage - elementTimeAdjustStart(String spanSysId, String newStartDateTimeMs)

Event handler for when a timeline span's start date was modified.

Table 15. Parameters
Name Type Description
spanSysId String The sys ID of the current span that is being adjusted.
newStartDateTimeMs String The new start time of the span in milliseconds. Make sure to parse the string using parseInt() prior to performing any numerical comparisons.
Table 16. Returns
Type Description
void

AbstractTimelineSchedulePage - getItems()

Event handler for returning schedule items to display on the timeline.

Table 17. Parameters
Name Type Description
none
Table 18. Returns
Type Description
void

AbstractTimelineSchedulePage - inputBox(String strInputText)

Event handler for when a string was typed into the left pane input box.

Table 19. Parameters
Name Type Description
strInputText String The text that was entered in the input box in the left pane.
Table 20. Returns
Type Description
void

AbstractTimelineSchedulePage - itemMove(String itemSysId, String newItemSysId)

Event handler for when a timeline row item was moved and dragged into another row item.

Table 21. Parameters
Name Type Description
itemSysId String The sys ID of the timeline item associated with the current span.
newItemSysId String The sys ID of the timeline item (a row) that the current span was dragged into.
Table 22. Returns
Type Description
void

AbstractTimelineSchedulePage - setDoReRenderTimeline(Boolean b)

Specifies whether or not to re-render all of the timeline items using the getItems() function.

Table 23. Parameters
Name Type Description
b Boolean If true, re-render the timeline by making a new event call to the server's getItems() handler.
Table 24. Returns
Type Description
void

AbstractTimelineSchedulePage - setPageTitle(String strTitle)

Specifies the text to display as the title of the timeline.

The page title can be set (and updated) from any interactive event; however, is recommended to be set during the getItems() event.

Table 25. Parameters
Name Type Description
strTitle String The text to be displayed on the timeline title.
Table 26. Returns
Type Description
void

AbstractTimelineSchedulePage - setStatusError(String strTitle, String strMessage)

Sets the current event request to an error status with a specified title and message to display in phase two of the GlideTimeline event processing.

Table 27. Parameters
Name Type Description
strTitle String The text to be displayed in the dialog box title.
strMessage String The text to be displayed within the dialog box. The text can contain HTML formatting.
Table 28. Returns
Type Description
void

AbstractTimelineSchedulePage - setStatusPrompt(String strTitle, String strOkFunction, String strCancelFunction, String strCloseFunction)

Sets the current event request to a prompt error status with a specified title and message to display in a confirmation dialog box during phase two of the GlideTimeline event processing. The confirmation box displays an OK and Cancel button that each generate new events that will call the functions specified the parameter arguments. The custom defined functions for OK, Cancel, and Close receive the same parameter arguments as those for the current event.

The confirmation box displays an OK and Cancel button that each generate new events that will call the functions specified the parameter arguments.
Note: The custom defined functions for OK, Cancel, and Close receive the same parameter arguments as those for the current event.
Table 30. Returns
Type Description
void

Example

var MyTimelineScriptIncludeClass = Class.create();
      MyTimelineScriptIncludeClass.prototype = Object.extendsObject(AbstractTimelineSchedulePage, {
      
      getItems: function() {
      //...
      },
      
      elementTimeAdjustEnd: function(spanSysId, newEndDateTimeMs) {
      // Display a status prompt dialog box
      this.setStatusPrompt('Confirm Action', 'Are you sure you want to do that?',
      'this._myOkHandlerFunction',  
      'this._myCancelHandlerFunction',
      'this._myCloseHandlerFunction');
      },
      
      _myOkHandlerFunction: function(spanSysId, newEndDateTimeMs) { // ... },
      
      _myCancelHandlerFunction: function(spanSysId, newEndDateTimeMs) { // ... },
      
      _myCloseHandlerFunction: function(spanSysId, newEndDateTimeMs) { // ... }
      };
    

AbstractTimelineSchedulePage - setStatusSuccess(String strTitle, String strMessage)

Sets the current event request to a success status with a specified title and message to display in phase two of the GlideTimeline event processing.

Table 31. Parameters
Name Type Description
strTitle String The text to be displayed in the dialog box title.
strMessage String The text to be displayed within the dialog box. The text can contain HTML formatting.
Table 32. Returns
Type Description
void