We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to fix deleted record.

Supriya25
Tera Guru

 

Hi All,

Kindly help me on below issue.

Supriya25_0-1769286044166.png

 

var gr = new GlideRecord("sys_history_line");
gr.addEncodedQuery("set=306b22cf93e676501a1bf6fa3d03d628^sys_idSTARTSWITH057ba2cf93e676501a1bf6fa3d03d656");
gr.query();
if (gr.next()) {
    gr.deleteRecord();
}

 I have executed above code in background script. after deletion of history line  I did check in Deleted record, delete recovery table , I didn't  find any trace around sys_history_line record which I deleted from background script. how it is possible ?

when I did check sys_audit table, there I saw one record  on 'sys_delete_recovery'  exact time match with my script execution . how it is possible. I didn't touch "delete recovery "table. 

Supriya25_0-1769284658057.png

Supriya25_1-1769284685839.png


now how can recover my 'history line'.

3 REPLIES 3

Bert_c1
Kilo Patron

That table is managed by the instance, deleted records there won't work. And that table will be refreshed when any user access the record's history.

Hi @Bert_c1 ,

thanks for reply, can you help me how to retrieve deleted history line.

Open then record, for ex. incident record, then right-click on the header or the hamburger menu icon, select History from the menu, then List. History set and history line records will be generated from the sys_audit table.

 

Screenshot 2026-01-24 205903.png