Name

global.ReleaseStatesUtil

Description

Utility for release , release phase and release tasks to track the state changes

Script

var ReleaseStatesUtil = Class.create();
ReleaseStatesUtil.prototype = {
  initialize: function(sysClassName) {
      if (JSUtil.nil(sysClassName))
          return;

      var gr = new GlideRecord(sysClassName);
      gr.initialize();
      this.stateElement = gr.state;
  },

  completedStateToggled: function(currentState, previousState) {
      return this.isCompletedState(currentState) !== this.isCompletedState(previousState);
  },


  isCompletedState: function(stateVal) {
      var completedStates = this.getCompletedStates();

      if (JSUtil.notNil(completedStates))
          return completedStates.indexOf(stateVal) > -1;

      return false;
  },


  getCompletedStates: function() {
      var completedStates = this.stateElement.getAttribute('completed_states');

      if (typeof completedStates === 'string')
          return completedStates.split(";");

      return null;
  },


  type: 'ReleaseStatesUtil'
};

Sys ID

1288af825bd2301074d09113a281c706

Offical Documentation

Official Docs: