Can I run the instant publish on articles in draft state?

bjhughey164
Mega Expert

Can I run the instant publish on articles already in draft state?

The articles have been created and vetted by our Knowledge team so I just need to move them to a published state. Is this possible?

1 ACCEPTED SOLUTION

Okay, this is hastily knocked up, and seems to work on articles that are currently draft but NOT "review":



(edited - <pre> tags barfed)



gs.log("1. Starting 'update-kb' script","UPDATE-KB");



gs.setSession.setStrictQuery(true);



// -- first, we use a GlideRecord against the Knowledgebase table


var pending = new GlideRecord('kb_knowledge');



// -- create our query:


pending.addEncodedQuery('workflow_state=draft^ORworkflow_state=review');



// -- call that query:


pending.query();



gs.log("2. found " + pending.getRowCount() + " records to update.","UPDATE-KB");



// -- now update each record found:


while(pending.next())


{


      // -- flick workflow state over


      gs.log("3. changing: " + pending.number + " to PUBLISHED.","UPDATE-KB");


      pending.workflow_state = 'published';


      pending.update();


}



gs.log("4. Completed script","UPDATE-KB");



This should write out to your script log, but under a different "source" so it should identify the records that have been amended, should you need an audit trail.   I trust you'll run it on a testbed first!


View solution in original post

16 REPLIES 16

If you wish to move all articles that are currently "draft" to show "published" then that'll take me 10-15 mins or so to knock up a server-side script to do the job, if that helps - given it's a one-off switchover.


Dave,



If you could help facilitate that, it would be great! It's a one-time instance for me but, may be beneficial to other's in the community as well. I've found over the last year or so I've gathered a whole heap of useful scripts!


Okay, this is hastily knocked up, and seems to work on articles that are currently draft but NOT "review":



(edited - <pre> tags barfed)



gs.log("1. Starting 'update-kb' script","UPDATE-KB");



gs.setSession.setStrictQuery(true);



// -- first, we use a GlideRecord against the Knowledgebase table


var pending = new GlideRecord('kb_knowledge');



// -- create our query:


pending.addEncodedQuery('workflow_state=draft^ORworkflow_state=review');



// -- call that query:


pending.query();



gs.log("2. found " + pending.getRowCount() + " records to update.","UPDATE-KB");



// -- now update each record found:


while(pending.next())


{


      // -- flick workflow state over


      gs.log("3. changing: " + pending.number + " to PUBLISHED.","UPDATE-KB");


      pending.workflow_state = 'published';


      pending.update();


}



gs.log("4. Completed script","UPDATE-KB");



This should write out to your script log, but under a different "source" so it should identify the records that have been amended, should you need an audit trail.   I trust you'll run it on a testbed first!


Test bed?! What's a test bed?!



Just kidding Dave, I'll give this a shot this afternoon. Thanks for all your help!


Ben Hughey wrote:



Test bed?! What's a test bed?!




Bwhahaha!



I found it doesn't work for articles already published (and in "review" stage), only for those in draft. Perhaps I need to add a routine that walks to the approval record and flicks it to "approved", but I'm guessing you could mass-update a large list of outstanding approvals jsut as easily.