Is there a way to mass retire KB articles?

Michael Bachme1
Kilo Guru

Instead of going into each KB article and clicking the 'Retire' button, looking for a script to do it.

1 ACCEPTED SOLUTION

Nia McCash
Mega Sage
Mega Sage

You can try to do this via a Background Script (see Background Scripts — ServiceNow Elite ).



The following retires ALL published KB articles.   You may want to modify the query to specify the conditions for the KB articles that you do want to retire (if not all).



var gr = new GlideRecord('kb_knowledge');


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


gr.query();


while(gr.next()) {


        gr.setValue('workflow_state','retired');


        gr.update();


}


View solution in original post

6 REPLIES 6

randrews
Tera Guru

the easiest way is from a list view.. filter the list down to JUST the ones you want to retire... right click the header and select update all.. then select retired from the drop down and click update



this option is ONLY available to admins generally and is a VERY easy way to update a list of records... just make sure you have filtered the list first so you have ONLY the records you want.


Scott Cornthwa1
Giga Contributor

Another method if you're planning on doing this sort of mass retirement on a regular basis, you can (or ask an admin to) make a copy via insert and stay of the "retire" UI action and have that be a list choice UI action (I would recommend using a copy so that you aren't customizing OOTB functionality and just adding functions). At that point you could then select the articles needing retiring in the list and select that list choice.



find_real_file.png



Just another way to do it, but I think you've got lots of options for it.