Not updated in Last 5 days

ankit_sharma487
Kilo Guru

tickets which are not updated in LAst 5 days - this reports i used to fetch via Updated RElative 5 days   filter. but later due to some business requirements i implemented a Schedule job which runs daily ad updates every ticket's DURATION field [current date - Created Date], but due to this every ticket is technically updated on daily basis

we want to see the ticket which were not updated [means Commented in Customer or Work Notes section]. can you help

t_anurag , sahityamalipeddi

1 ACCEPTED SOLUTION

use this



var nonInc = new GlideRecord('task');


nonInc.addEncodedQuery('active=true^sys_class_name!=incident');


nonInc.autoSysFields(false);


nonInc.query();


//gs.log("Found " + nonInc.getRowCount() + " records");


while(nonInc.next()){


      var now = gs.nowDateTime();


      var opened = nonInc.opened_at.getDisplayValue();


      var calDur = gs.dateDiff(opened, now, false);


      nonInc.calendar_duration = calDur;


      nonInc.update();


}



var inc = new GlideRecord('incident');


inc.addEncodedQuery('active=true^state!=6');


inc.autoSysFields(false);


inc.query();


//gs.log("Found " + inc.getRowCount() + " incident records");


while(inc.next()){


      var now = gs.nowDateTime();


      var opened = inc.opened_at.getDisplayValue();


      var calDur = gs.dateDiff(opened, now, false);


      inc.calendar_duration = calDur;


      inc.update();


}


-Anurag

View solution in original post

7 REPLIES 7

Anurag Tripathi
Mega Patron
Mega Patron

Hi Ankit,



Use this in your scheduled job



autoSysFields(false);



This will not update the system fields inlcuding update on and hence your filter will work. Read more here



GlideRecord - ServiceNow Wiki


-Anurag

Thanks Anurag for your kind support, i have added to my scheduled job, will confirm you back tomorrow . Thanks once again


Hey Ankit,



Did this work??


-Anurag

hi t_anurag, i have this scheduled job , but i am seeing after adding the suggested one that yesterday even this updated the tickets , is there something i am making mistake?



var nonInc = new GlideRecord('task');


nonInc.addEncodedQuery('active=true^sys_class_name!=incident');


nonInc.query();


//gs.log("Found " + nonInc.getRowCount() + " records");


while(nonInc.next()){


      var now = gs.nowDateTime();


      var opened = nonInc.opened_at.getDisplayValue();


      var calDur = gs.dateDiff(opened, now, false);


      nonInc.calendar_duration = calDur;


      nonInc.autoSysFields(false);


      nonInc.update();


}



var inc = new GlideRecord('incident');


inc.addEncodedQuery('active=true^state!=6');


inc.query();


//gs.log("Found " + inc.getRowCount() + " incident records");


while(inc.next()){


      var now = gs.nowDateTime();


      var opened = inc.opened_at.getDisplayValue();


      var calDur = gs.dateDiff(opened, now, false);


      inc.calendar_duration = calDur;


      inc.autoSysFields(false);


      inc.update();


}