Retire KB Automatically

rc393g
Kilo Explorer

Hi All,

I would like to seek you help on how I can verify that our Knowledge Article will be retired after the valid to date. Will this be OOB in Fuji for Knowledge Management.

Appreciate your help!

1 ACCEPTED SOLUTION

Tanaji Patil
Tera Guru

Hi,



Use this code-



var kb = new GlideRecord('kb_knowledge');


kb.addQuery('workflow_state','!=','retired');


kb.addQuery('valid_to','<',gs.now().toString());


kb.query();


while(kb.next()){


  var workflow = new Workflow();


  workflow.cancel(kb);         //this will cancel all workflow contexts with the record


  kb.workflow_state = 'retired';


  kb.update();


}



This should work.



If you are using workflow for knowledge article flow then I would recommend you to use 'Wait for condition' with condition 'valid to at or before Today' followed by 'Set values' activity.



Have a good day



Thanks,


Tanaji


View solution in original post

11 REPLIES 11

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi,



I don't think OOB KB article's will be retired. However you can set up a script which will will make the status to retired based on the valid to date.


Thank you, Pradeep! Will you be able to share the script and how this should be setup?



Appreciate your help!


Mike Allen
Mega Sage

You could set up a scheduled job that will go in and retire all articles for which the 'valid to' date has passed.


Thanks, Mike! Can you also share how we can setup the scheduled job? Btw, we are using Fuji now.



Appreciate your help!