- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 11:25 AM
how can i have a scheduled job check for knowledge articles with no activity. I would like to ensure that published Knowledge Articles with a "valid to" date of before today or not updated in more than a year are made inactive and are not available in the relevant KB
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 10:31 PM
Hi,
Please update your Scheduled job script as below:
retireArticles();
function retireArticles(){
var gr = new GlideRecord('kb_knowledge');
gr.addEncodedQuery('workflow_state=published^valid_to<javascript:gs.beginningOfToday()^sys_updated_onRELATIVELT@year@ahead@1');
gr.query();
while(gr.next()){
gr.workflow_state = 'retired';
gr.active = false;
gr.setWorkflow(false);
gr.update();
}
}
Alternatively, you can also use Flow Designer which is a no code approach to do the similar activity.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 01:07 PM
Hi,
I believe you will require something like:
var kb = new GlideRecord("kb_knowledge");
kb.addEncodedQuery("valid_to<javascript:gs.beginningOfToday()^sys_updated_on<=javascript:gs.beginningOfOneYearAgo()");
kb.query();
while (kb.next()){
kb.active=false;
kb.update();
}
Now what are your trigger conditions that is for you to evaluate.
Hope this helps!
Tudor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 05:19 PM
Thanks for sharing this, but it seems that the articles still say active.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 06:02 PM
Hi you cant make knowledge articles inactive. You need to retire the kb article . Making retired will not display articles on the portal or native UI.
var kb = new GlideRecord("kb_knowledge");
kb.addEncodedQuery("valid_to<javascript:gs.beginningOfToday()^sys_updated_on<=javascript:gs.beginningOfOneYearAgo()");
kb.query();
while (kb.next()){
kb.active=false;
kb.workflow_state = 'retired';
kb.update();
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 10:31 PM
Hi,
Please update your Scheduled job script as below:
retireArticles();
function retireArticles(){
var gr = new GlideRecord('kb_knowledge');
gr.addEncodedQuery('workflow_state=published^valid_to<javascript:gs.beginningOfToday()^sys_updated_onRELATIVELT@year@ahead@1');
gr.query();
while(gr.next()){
gr.workflow_state = 'retired';
gr.active = false;
gr.setWorkflow(false);
gr.update();
}
}
Alternatively, you can also use Flow Designer which is a no code approach to do the similar activity.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke