Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Mark several incident tickets as spam

 

Warning, Resolving an Incident will NOT PREVENT the SLA breach notifications from sending. To fully stop an SLA Breach, the Incidents must be set to state Closed, which is '7'.

Code Block
//var incidents = ["INC0333439"];
//var caller = 'somit@yale.edu';
// sys_id for somit@yale.edu
var u_sys_id = '6bb31c742bd62500fcb01abf59da1546';
var date = '2014-07-31';
var state = '6';
var inc_num = '';
// state 6 is resolved
 
    var gr = new GlideRecord('incident');
    gr.addQuery('caller_id',u_sys_id);
    gr.addQuery('opened_at','ON',date);
    gr.query();
 
    var counter=0;
    while (gr.next()) {
      inc_num = gr.number;
      gs.print(inc_num);
      update_one_inc(inc_num);
      counter++;
    }
    gs.print("counter is: " + counter);
    gs.print("inc_num is: " + inc_num);
 
// the portion above successfully found 1032 incidents!

function update_one_inc ( inc_num) {
 var gr2 = new GlideRecord('incident');
 gr2.addQuery('number',inc_num);
 gr2.query();
 if ( gr2.next() ) {
   gr2.incident_state = state;
   gr2.u_incident_type = 'Invalid';
   // incident type 5 is 'invalid'
   gr2.u_level_1 = 'Data';
   //gr2.u_it_provider_service = 'Other IT Provider Service';
   gr2.u_it_provider_service = '22bc2a165d7718007ac08a508e67e8fe';
   //gr2.u_it_business_service = 'Other IT Business Service';
   gr2.u_it_business_service = 'f3aaaad25d7718007ac08a508e67e875';
   gr2.description = 'Spam email';
   gr2.close_code = 'Invalid Incident';
   // close code 9 is 'invalid incident'
   gr2.close_notes = 'Spam email';
   gr2.autoSysFields(false);
   gr2.setForceUpdate(true);
   gr2.setWorkflow(false);
   gr2.update();
 }
}

...