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

1 ACCEPTED SOLUTION

vaishali231
Kilo Sage

Hey @seelamnandh 

This behavior is expected unless article expiry automation is configured.

The Valid To field alone does not automatically hide or retire a Knowledge Article from Global Search in Native UI. If the article is still:

  1. in Published state
  2. Active = true
  3. and indexed by search

then it can continue appearing in search results even after the Valid To date has passed.

Please verify the following:

  1. Check whether any Knowledge expiry/retirement scheduled job is active.
  2. Confirm whether a Knowledge lifecycle workflow/flow is configured to automatically retire expired articles.
  3. Rebuild or refresh the search index if the article was recently updated.
  4. If using AI Search or custom search sources, ensure expired articles are excluded using conditions like:
valid_toISEMPTY^ORvalid_to>=javascript:gs.nowDateTime()

OOB, the valid_to field is mostly informational and does not automatically change the workflow state to Retired.

As a solution, you can create a Scheduled Script/Flow to retire expired articles automatically.

 Scheduled Script:

var gr = new GlideRecord('kb_knowledge');

gr.addQuery('workflow_state', 'published');

gr.addQuery('valid_to', '<', gs.nowDateTime());

gr.query();

while (gr.next()) {

    gr.workflow_state = 'retired';

    gr.active = false;

    gr.update();

}

 

After retirement, reindex Knowledge Search if the article still appears in Global Search.

****************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.

Doing so helps others in the community and encourages me to keep contributing.

Regards

Vaishali Singh

Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb



View solution in original post

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();
}