Regarding Rollback deleted records by using condition created on

sivakumaraa
Mega Contributor

Hi,

 

My question is how to retrieve the deleted records in incidents by using condition created on. But we need to use server side script like fix or background script, can you please give suggestion how to write script.

This is my script:

var del = new GlideRecord('sys_audit_delete');
del.addQuery('sys_updated_on', 'ON ', '2026 - 05 - 20 ');
del.query();
while (del.next()) {
    var rollback = new GlideRollback();
    rollback.rollbackSequence(del);
    gs.print('Rolled back sequence: ' + del.sys_id);
}
gs.print(' Error Rolled back sequence: ' + del.sys_id);
 
can you please modify and update the script
1 REPLY 1

Tanushree Maiti
Giga Patron

Hi @sivakumaraa 

 

Try this:  

Run the following script using Fix Scripts or Scripts - Background. Always test this in a non-production instance first.

 

Note: In script replace Var date  as per the screen shot:

Screenshot 2026-05-31 021409.png

var del = new GlideRecord('sys_audit_delete');
var date = "sys_created_onON2026-05-20@javascript:gs.dateGenerate('2026-05-20,'start')@javascript:gs.dateGenerate('2026-05-20','end')";

del.addEncodedQuery(date);
del.query();
while(del.next())
{
new GlideAuditDelete().undelete(del.sys_id);
}

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: