- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2017 03:27 AM
Hello Everyone,
I have around 8700 restored records from knowledge table which needs to be archived again.
But while running a new Archive Rule I see below error message.
Running archive rule: Archiving older Knowledge Articles from KB V2. 9503 record(s) cannot be re-archived because they have been restored.
Can anyone please advise.
Regards,
Sagarika Das
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 04:09 AM
First of all, if it's a one time off, you shouldn't use a UI action for it. You should maybe create a scheduled script execution.
And you need to adapt your script a bit. Does this work for one record if you run it via background scripts?
var gr = new GlideRecord('ar_kb_knowledge');
gr.addQuery('kb_knowledge_base','dfc19531bf2021003f07e2c1ac0739ab');
gr.addQuery('dateGenerate','<','2017-01-01','12:00:00');
gr.addQuery('category','Planned Downtime');
gr.addOrCondition('category','Unplanned Downtime');
gr.setLimit(1);
gr.query();
while(gr.next()) {
gs.print('Archiving record with number: ' + gr.number);
try {
new GlideArchiveRecord().archive(gr);
}
catch(err) {
gs.log('Error returned is: ' + err);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2017 05:08 AM
In the record, under Related Link - there should a UI action that will re-restore the record. I believe you can make that a List Choice so you can do them in bulk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 03:59 AM
Thanks Michael,
Here I am trying to Re-archive a bunch of restored records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2017 06:16 AM
You can do a GlideRecord call on all those records you want to re-archive and just run on them:
new GlideArchiveRecord().archive(current);
That's what the UI action does anyway.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 03:58 AM
Thanks Sergiu,
I have created a new UI Action called Re-archive Now under the same Archive Rule.
I have used below query and ran it but it does not archive anything. Hence, I am not sure what's happening. Can you please suggest something.
var gr = new GlideRecord('ar_kb_knowledge');
gr.addQuery('kb_knowledge_base','dfc19531bf2021003f07e2c1ac0739ab');
gr.addQuery('dateGenerate','<','2017-01-01','12:00:00');
gr.addQuery('category','Planned Downtime');
gr.addOrCondition('category','Unplanned Downtime');
gr.query();
while(gr.next())
{
new GlideArchiveRecord().archive(current);
}
Regards,
Sagarika