Script to delete the KBs draft version

Siddhartha
Tera Contributor

We have a requirement to delete the draft version of thousands of KBs, Looking for a script for the same.

 

In the data, We have KB number & version number & workflow=draft.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Mike_R
Kilo Patron
Kilo Patron

This script will delete all Knowledge articles where state/workflow = draft. Please test out in subprod first. I would also suggest using this in a fix script and run it in the background.

 

var kb = new GlideRecord('kb_knowledge');
kb.addEncodedQuery('workflow_state=draft');

kb.setWorkflow(false);
kb.deleteMultiple(); //Deletes all records in the record set

View solution in original post

2 REPLIES 2

Mike_R
Kilo Patron
Kilo Patron

This script will delete all Knowledge articles where state/workflow = draft. Please test out in subprod first. I would also suggest using this in a fix script and run it in the background.

 

var kb = new GlideRecord('kb_knowledge');
kb.addEncodedQuery('workflow_state=draft');

kb.setWorkflow(false);
kb.deleteMultiple(); //Deletes all records in the record set

thanks Mike_R.