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

Bharath40
Giga Guru

Hi,



You can do it from list view , refer to below thread


http://wiki.servicenow.com/index.php?title=Editing_Lists or you can write a script to do a GlideRecord to this table and update the records based on conditions.


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


}


Does this work on Knowledge v3?


Yes. But you may need to modify the query and you should familiarize yourself with Background Scripts and the risks if you've never used before.