Wednesday, October 30, 2013

Mass un-delete

Well I finally did it. Yes that's right I managed to write a business rule that was so well tested that it deleted all 12000 change tasks in our system. Whoops! Not too big of a deal right?! Thankfully I caught it pretty quickly and managed to run the below script which set everything straight. It was a bit too cumbersome to undelete them 100 at a time from the list view.

var count = 0;
var cur = new GlideRecord('sys_audit_delete');
cur.setWorkflow(false);
cur.addEncodedQuery('tablename=change_task^sys_created_onONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)');
cur.query();
while(cur.next()){
count ++;
var und = new GlideAuditDelete().get(cur.documentkey);
und.insert();
cur.deleteRecord();
}
gs.print(count);
view raw gistfile1.js hosted with ❤ by GitHub

No comments:

Post a Comment