Expired articles are visible in global search

seelamnandh
Tera Contributor

Even after the knowledge article’s Valid To date has been passed, the article is still visible to all users in the global search(Native UI). The workflow state of this article is still published, and valid to date is passed

10 REPLIES 10

JulietD
Mega Guru

Add a Scheduled Job 

Automatically retire articles when Valid To is reached. 

 
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('valid_to', '<=', gs.nowDateTime());
gr.addQuery('workflow_state', 'published');
gr.query();

 

while (gr.next()) {
    gr.workflow_state = 'retired';
    gr.update();
}