Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 18 Next »

Mark several incident tickets as spam

//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();
 }
}

Reopen closed incidents

var incidents = ["INC0145723","INC0145726","INC0145736","INC0145721","INC0145718","INC0145729","INC0145722","INC0145727","INC0145716","INC0145711"];
var state = '3';

for (i=0; i<incidents.length; i++) {
    var gr = new GlideRecord('incident');
    gr.addQuery('number',incidents[i]);
    gr.query();
    if(gr.next()) {
        gs.print("old state = " + gr.incident_state);
        gr.incident_state = state;
        gr.update();
    }
}

Lou often gives us lists of change fields

Here's how to make them better with bash. This still needs some work, but is better than nothing:

[db692@mas013-new ~]$ cat asdf
CHG0006629
CHG0004449
# the next line is for gnu sed
[db692@mas013-new ~]$ echo -n "var changes = [\""; cat asdf | sed ':a;N;$!ba;s/\n/","/g'
var changes = ["CHG0006629","CHG0004449
# here's one for MAC (BSD) sed
zuse:~ db692$ echo -n "var incidents = [\""; cat jkl | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/'\",\"'/g'
var incidents = ["INC0145723","INC0145726","INC0145736","INC0145721","INC0145718","INC0145729","INC0145722","INC0145727","INC0145716","INC0145711
  • No labels