Script to update stage of a KB

si21
Tera Guru

Hi experts,

we have a KB article that is stuck in pending retirement stage. Hi team suggested us to use background script to update the stage to published.

 

var gr = new GlideRecord('kb_knowledge');
gr.addQuery('sys_id','ac0ab4c247373d10bc09483d416d4325');
gr.query();
if(gr.next())
{
       gr.workflow_state = 'published';
       gr.update();
}

But script is not working for this particular article. Could you please share the fix script or background script.

 

 

TIA

2 REPLIES 2

Sai_Charan_K
Kilo Sage

Hi @si21 ,

I do not see any issues with the script you are using, I tried using the same script in my PDI and I was able to update the KB state as well. If possible can you please share the screenshot of the error which you are receiving ?

var gr = new GlideRecord("kb_knowledge");
gr.addQuery("sys_id","53e0c9b1474321009db4b5b08b9a71fd");
gr.query();
if(gr.next()){
	gs.print(gr.number);
	gr.workflow_state="published";
	gr.update();
}

Please find the screenshot of the execution attached.

Please mark my answer "Helpful" if you feel that it has helped you in any way.

Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India



Sai_Charan_K
Kilo Sage

Hi @si21 ,

Please go through this link - https://www.servicenow.com/community/knowledge-managers/articles-stuck-in-pending-retirement/m-p/305... and check if you have a similar issue. If so please follow the below steps:

  1. Retire the latest published article.
  2. Re-publish the retired article from earlier step

These steps should help in retiring the article which was in pending retirement state.

 

Please mark my answer "Helpful" and mark this as "Correct" if you feel that it has helped you in any way.

Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India