- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 06:58 AM
I am trying to archive all of our incidents and the archive rules will not allow me to do so because we had to restore all of them because we forgot a crucial step in our archiving process. I was able to restore all of the records through a script, but am unable to rearchive them through a script after we have filled in a field for all of them. Why does this method not work or the archive rule not work?
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 07:05 AM
Sample script : This will query all incident records. You can filter the records by using addQuery() as per your req
var gr = new GlideRecord('incident');
gr.query();
while(gr.next())
{
new GlideArchiveRecord().archive(gr);
}
Note: Untested

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 07:02 AM
Hello Alec,
You need to pass the glideRecord object instead of current when doing it via Fix script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 07:05 AM
Sample script : This will query all incident records. You can filter the records by using addQuery() as per your req
var gr = new GlideRecord('incident');
gr.query();
while(gr.next())
{
new GlideArchiveRecord().archive(gr);
}
Note: Untested
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2017 03:35 PM
Alec,
We are glad you took advantage of the ServiceNow Community to learn more and to get your questions answered. The Customer Experience Team is working hard to ensure that the Community experience is most optimal for our customers.
If you feel that your question was answered, we would greatly appreciate if you could mark the appropriate thread as "Correct Answer". This allows other customers to learn from your thread and improves the ServiceNow Community experience.
If you are viewing this from the Community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thanks,
Shivani Patel