Name

sn_grc.IGContentToAddtlEntityActionHandler

Description

No description available

Script

var IGContentToAddtlEntityActionHandler = Class.create();
IGContentToAddtlEntityActionHandler.prototype = {
  initialize: function(action, strategy) {
      this.actionType = action.action;
      this.itemTable = action.table;
      this.entityId = action.entity_id;
      this.contentId = action.content_id;
      this.source = action.source;
      this.strategy = new sn_grc.ItemGenerationV2Utils().getStrategy(this.itemTable);
  },

  execute: function() {
      if (this.actionType == 'add_content_to_addtl_entity') {
          this._addContentToAddtlEntity();
      } else if (this.actionType == 'remove_content_from_addtl_entity') {
          this._removeContentFromAddtlEntity();
      }
  },

  _addContentToAddtlEntity: function() {
      this.strategy.generateItem(this.entityId, this.contentId, this.entityId);
  },

  _removeContentFromAddtlEntity: function() {
      var util = new ItemGenerationV2Utils();
      var itemTable = this.strategy.itemTable;
      var itemGR = new GlideRecord(itemTable);
      itemGR.addQuery('content', this.contentId);
      itemGR.addQuery('profile', this.entityId);
      itemGR.addQuery('source', 'CONTAINS', this.entityId);
      itemGR.addQuery('instance', 'true');
      itemGR.setLimit(1);
      itemGR.query();
      if (itemGR.next()) {
          util.deleteSourceInItem(itemGR, this.entityId);
      }
  },

  type: 'IGContentToAddtlEntityActionHandler'
};

Sys ID

ee50bf2dc78720109081f73224c26043

Offical Documentation

Official Docs: