
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 09:39 AM
I was removing choices from a variable and there were 250+ choices, so I thought to use a script which ended up deleting everything from the table Question_choices.I've deleted all the 15K choices from Question_choices table mistakenly. When I checked for the restore option, I didn't find anything which can restore all the records in one go. I found this solution on another thread on the community:
Navigate to System Definition > Deleted Records.
- Open a deleted record that you want to restore.
Note: You can only restore one deleted record and its associatd references at a time.
- In the Audit Deleted Record form, select Restore Record and References under Related Links.
Note: To restore the record without restoring the references, select Undelete RecordI selected 100 records at a time in list view and restored everything. My question here is how can I do it in less time as restoring 15K records with this option took me 2 hours. Is there any other way we can do it.Note of caution - Please read all the follow-up comments before running the script from Correct Answer, as it has syntax error that may cause issues if you run without correcting it.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 09:50 AM
I would say that you should stay away from scripts given what has happened...but...lessons aside: Try this in a background script...you'd need to fix your encodedquery to grab what you're looking for.
var deleted = new GlideRecord('sys_audit_delete');
deleted.addEncodedQeury('put query here');
deleted.query();
while(deleted.next()){
new GlideAuditDelete().undelete(deleted.sys_id);
}
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2019 11:10 AM
I'm unable to edit the post and if you read through this all the way, you'd have seen the correction and my acknowledgement.
Sorry for the trouble that was caused, but this could have been avoided if you read all the way.
We should be appreciative enough for the help that was given in the first place.
Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 09:21 AM
Allen - I have similar request and I'm trying to restore 700,000 records - how long does it take, if i schedule this in Schedule Job?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2021 07:02 AM
Content Admin: We might want to take consider taking this post down and restore it elsewhere... some people are reading quickly and don't read through all the comments. I know of a company recently that ran this script on their own environment and caused a massive restore problem -- because of the wrong syntax it ignored the filter altogether. This post is a bit of a liability I think...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2021 08:39 AM
Hi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 04:36 PM
@Sontel How did you resolve the issue when it restored all the records?
Is there an identifier which tells us what was restored
Please mark this response as correct or helpful if it assisted you with your question.