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 11:13 AM
Hi
Want to add that along with Draft, suggestion here will be to also consider only those articles whose Valid to date is in past as mentioned in your query as well.
My version of script will be to look at Articles which are not Published and whose Valid to date is in past then make those articles as retired.
Please write a Fix Script and use the script as below:
Also do make use of setworkflow as false to avoid any unnecessary Notification from getting triggered when you are updating these articles.
retireArticles();
function retireArticles(){
var gr = new GlideRecord('kb_knowledge');
gr.addEncodedQuery('sys_class_name!=kb_knowledge_block^workflow_state!=published^valid_to<javascript:gs.beginningOfToday()');
gr.query();
while(gr.next()){
gr.workflow_state = 'retired';
gr.setWorkflow(false);
gr.update();
}
}
Screenshots for reference:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke