How to Retired a Knowledge Article that hasn't been Published
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 08:11 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 08:26 AM
You can configure and run a fix script to updates these kb articles as retired.
Below is the sample script which retires KB articles.
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('workflow_state','draft');
gr.query();
while(gr.next()) {
gr.setValue('workflow_state','retired');
gr.update();
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 09:53 AM
So we would go through and Publish what we want and leave all in Draft we don't and then run this script (it would run on all in Draft state), is that correct?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 10:01 AM
Yes, this script will run for draft state knowledge articles.
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 10:53 AM
Hello Carlav,
Please write fix script but make sure you log count and cross check how many where there and also don't forgot to add gr.setWorkflow(false) otherwise it will trigger notifications and all and lastly run fix script in background, that option will come once you click on 'Run fix script' button. Mark my answer as correct or hit like based on impact.
var count = 0;
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('workflow_state','draft');
gr.query();
while(gr.next()) {
count++;
gr.workflow_state = 'retired';
gr.setWorkflow(false);
gr.update();
}
gs.print("Total number of article moved to Retired state is: " + count);
Regards,
Musab