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.

Publishing the knowledge article through fix script

phr
Tera Contributor

Hi All,

 

I have 2 versions are KB article one published and another needs to be published.

phr_0-1724246728646.png

The ask is i need to publish the version 12.02 which is in the review state currently.

I did write a fix script code and put the sys id of the version 12.02. But still the article isn't getting published and is still in the review state.

Fix script code:

 

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

 

How to achieve this?

 

 

1 REPLY 1

Hemanth M1
Giga Sage
Giga Sage

Hi @phr 

Try this , use serWorkflow(false) before the update if you wanna skip the workflow to trigger.

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

 

Hope this helps!!!

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025