KB article not moved to retired after valid to date

Sarabjeet1
Tera Contributor

Hi,

knowledge article in system has passed the valid to date but workflow is still showing published. Ideally it should move to Retire but it is not happening. There is no way to check workflow execution for that kb article. Please let me know if anyone knows why is this happening. PFB screenshot for reference.

Sarabjeet1_0-1704458719808.png

 

1 ACCEPTED SOLUTION

Hi @Sarabjeet1,

Here's a script you can use in a Scheduled Job.

 

Please mark correct and helpful.

 

Thanks,

Robbie

 

var retireKB = new GlideRecord('kb_knowledge');

retireKB.addEncodedQuery("workflow_state=published^retired<javascript&colon;gs.daysAgoStart(0)"); //change 0 to the number of days ago

retireKB.query();

while(retireKB.next()) {

retireKB.workflow_state ='retired';

retireKB.active=false;

retireKB.update();

retireKB.log('Knowledge article retired' +retireKB.number);

}

View solution in original post

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Sarabjeet1 

 

Knowledge article validity is the date a knowledge article expires. Articles do not appear in search results after the Valid to date or if the Valid to date is blank

 

Its expire not Retired. 

 

https://docs.servicenow.com/bundle/vancouver-servicenow-platform/page/product/knowledge-management/c...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

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

Hi Atul,

Thanks for your quick response. could you please let me know if i have to retire it manually  each time as there is no approval attached to this expired article or how will this proceed. 

Hi @Sarabjeet1 

 

You can retire the articles manually by clicking the UI action and if any notification mapped it will trigger or check the knowledge base Retire Workflow.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

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

Hi @Sarabjeet1,

Here's a script you can use in a Scheduled Job.

 

Please mark correct and helpful.

 

Thanks,

Robbie

 

var retireKB = new GlideRecord('kb_knowledge');

retireKB.addEncodedQuery("workflow_state=published^retired<javascript&colon;gs.daysAgoStart(0)"); //change 0 to the number of days ago

retireKB.query();

while(retireKB.next()) {

retireKB.workflow_state ='retired';

retireKB.active=false;

retireKB.update();

retireKB.log('Knowledge article retired' +retireKB.number);

}