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.

automatic publishing

JulietChicago
Tera Guru

We have knowledge article that come in via an integration in the Draft state. We want the articles to be published automatically without a person having to select the "published" button. How can we do this?

 

 

1 REPLY 1

SatyakiBose
Mega Sage

Hello @JulietChicago 

You can run this script in background or as a schedule job to bulk publish KB articles.

gs.log("1. Starting 'update-kb' script","UPDATE-KB");
gs.setSession.setStrictQuery(true);
var pending = new GlideRecord('kb_knowledge');
pending.addEncodedQuery('workflow_state=draft^ORworkflow_state=review');
pending.query();
gs.log("2. found " + pending.getRowCount() + " records to update.","UPDATE-KB");
while(pending.next())
{
      gs.log("3. changing: " + pending.number + " to PUBLISHED.","UPDATE-KB");
      pending.workflow_state = 'published';
      pending.update();
}
gs.log("4. Completed script","UPDATE-KB");