Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

FIx Script to update a field in knowledge article

RudhraKAM
Tera Guru

Hello There 

 

I have a Knowledge article where state is set to review , even though its approved , not sure where to check the workflow ,for a work around how to update the workflow status to published just for that kb article using fix script ?

1 ACCEPTED SOLUTION

Rajesh Mushke
Mega Sage

Hey Kam,

 

Create a fix script with below script and make few changes as per your requirements.

 

var kb = new GlideRecord("kb_knowledge");
kb.addEncodedQuery("number=KB0010002"); // change the article number
kb.query();
if(kb.next()){
kb.workflow_state="published";
kb.update();
kb.setWorkflow(false);
}

 

i hope this will helpful to you, let me know if you need more details.

 

Thanks,

Rajashekhar Mushke

Community Leader 



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

View solution in original post

2 REPLIES 2

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

use this script as example and run it as Fix Scripts:

var gr = new GlideRecord('kb_knowledge');
gr.addQuery('sys_id','<enter the sys_id of the kb article>');
gr.query();
while(gr.next())
{
       gr.workflow_state = 'published';
       gr.update();
}

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

Rajesh Mushke
Mega Sage

Hey Kam,

 

Create a fix script with below script and make few changes as per your requirements.

 

var kb = new GlideRecord("kb_knowledge");
kb.addEncodedQuery("number=KB0010002"); // change the article number
kb.query();
if(kb.next()){
kb.workflow_state="published";
kb.update();
kb.setWorkflow(false);
}

 

i hope this will helpful to you, let me know if you need more details.

 

Thanks,

Rajashekhar Mushke

Community Leader 



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke