Name

sn_sow_em.SOWAlertRouteUtil

Description

Implements extension point sn_sow_record.SOWRouteUtil

Script

var SOWAlertRouteUtil = Class.create();
SOWAlertRouteUtil.prototype = Object.extendsObject(sn_sow.SOWDefaultRecordRouteUtil, {
  TABLE_ALERT: 'em_alert',
  TABLE_ANOMALY_ALERT: 'em_alert_anomaly',
  IS_CMDB_CI_EXTENSION: false,
  ALERT_TABS: [],

  initialize: function() {},

  handles: function(table, sysId) {
      // If the table is em_alert or em_alert_anomaly or an extension of cmdb_ci
      this.IS_CMDB_CI_EXTENSION = new sn_cmdb_pg_templts.CMDBPageTemplatesUtility().isExtensionOfCmdbCi(table);
      return table === this.TABLE_ALERT || table === this.TABLE_ANOMALY_ALERT || this.IS_CMDB_CI_EXTENSION === true;
  },

  getOtherRoutes: function(table, sysId) {
      if (table === this.TABLE_ANOMALY_ALERT) {
          // For em_alert_anomaly table, show Metrics tab if cmdb_ci is not empty
          var alertAnomalyGr = new GlideRecord(this.TABLE_ANOMALY_ALERT);
          if (alertAnomalyGr.get(sysId)) {
              if (alertAnomalyGr.cmdb_ci + '' !== '') {
                  this.RESULT.routes.push(new sn_sow_em.SOWAlertRecordTabUtils().getMetricsTabRoute());
              }
          }
      } else if (table === this.TABLE_ALERT) {
          // For em_alert table, get tab routes (internally depends on Alert type)
          var alertGr = new GlideRecord(this.TABLE_ALERT);
          if (alertGr.get(sysId)) {
              var tabs = new sn_sow_em.SOWAlertRecordTabUtils().getAlertRecordTabsToShow(alertGr);
              for (var i = 0; i < tabs.length; i++) {
                  this.ALERT_TABS.push(tabs[i]);
              }
              var routes = new sn_sow_em.SOWAlertRecordTabUtils().getAlertRecordTabRoutes(alertGr);
              for (var j = 0; j < routes.length; j++) {
                  this.RESULT.routes.push(routes[j]);
              }
          }
      } else {
          // For cmdb_ci table, show Metrics tab always
          this.RESULT.routes.push(new sn_sow_em.SOWAlertRecordTabUtils().getMetricsTabRoute());
      }
      return;
  },

  getPlaybookRoute: function(table, sysId) {
      if (this.ALERT_TABS.indexOf(SOWAlertRecordTabUtilsSNC.RECORD_TAB_KEYS.PLAYBOOK) !== -1 && this.hasPlaybook(table, sysId)) {
          this.RESULT.routes.push(this.COMMON_ROUTES.PLAYBOOK);
      }
      return;
  },

  getRelatedListRoutes: function(table, sysId) {
      if (sysId !== "-1" && (this.ALERT_TABS.indexOf(SOWAlertRecordTabUtilsSNC.RECORD_TAB_KEYS.RELATED_RECORDS) !== -1 || this.IS_CMDB_CI_EXTENSION)) {
          this.RESULT.relatedListRoutes.push(this.COMMON_ROUTES.RELATED_LIST_COLLECTION);
      }
      return;
  },

  type: 'SOWAlertRouteUtil'
});

Sys ID

0864e05e0bc201105f02818393673af1

Offical Documentation

Official Docs: