Name

global.InterProjectEventProcessor

Description

Event processor - raises notification and accepts notification if needed

Script

var InterProjectEventProcessor = Class.create();
InterProjectEventProcessor.prototype = {
  initialize: function() {
  },

  process: function(topTaskId, dirtyTasks) {
      PPMDebug.log("Into InterProjectEventProcessor.process -> " + topTaskId);
      if( JSUtil.notNil(topTaskId) && JSUtil.notNil(dirtyTasks) ) {
          var notificationHandler = new PlannedTaskNotificationHandler();
          var processor = new ShadowTaskProcessor();
          var tasks = (new JSON()).decode(dirtyTasks);
          for (var i = 0; i < tasks.length; i++) {
              var task = tasks[i];
              var relationApplied = task.relation_applied;
              if(JSUtil.notNil(relationApplied)) {
                  var relationRecord = ShadowTaskQueryHelper.relationRecord(relationApplied);
                  // Check if this relation record is affecting the task start date
                  if(processor.shouldProcess(task)) {
                      var event = notificationHandler.raiseNotification(task.sys_id, task.orig_sys_id, task.relation_applied, task.previous_start_date);
                      PPMDebug.log("Into InterProjectEventProcessor.process: relationApplied -> " + relationApplied);
                      var relation = ShadowTaskQueryHelper.relationRecord(relationApplied);
                      if ( relation.isValidRecord() && ShadowTaskQueryHelper.shouldProcessRelationImmediately(relation.sys_id) ) {
                          PPMDebug.log("Into InterProjectEventProcessor.process -> acceptNotification" );
                          var notifRecord = event.record;
                          // re-query the notification - as dot walk records are missing
                          var notifRecordSysId = notifRecord.getValue("sys_id");
                          var notificationGr = new GlideRecord("planned_task_notification");
                          if(notificationGr.get(notifRecordSysId)) {
                              notificationHandler.acceptNotification(notificationGr);
                          }
                      }
                  }
              }
          }
      }
  },

  processForFullRecalculate: function (topTaskId) {
      PPMDebug.log("Into InterProjectEventProcessor.processForFullRecalculate -> " + topTaskId);
      if(JSUtil.notNil(topTaskId)) {
          var api = new SNC.PlannedTaskAPI();
          api.fullRecalculate(topTaskId);
      }
  },

  type: 'InterProjectEventProcessor'
};

Sys ID

456257a59fa22200598a5bb0657fcf15

Offical Documentation

Official Docs: