- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 06:25 AM
Hi Community,
I have around 500 KB articles which are currently in draft state. There is a button at the top "Submit for review" when clicked it changes the state of knowledge article to publish.
How can i invoke this button "Submit for review" for all 500 articles at once.
1. Article in draft state.
2. When we click on "Submit for review".
3. Ui Action "Submit for review".
Condition : current.workflow_state == 'draft' && (current.author == gs.getUserID() || gs.hasRole('knowledge_admin') || gs.hasRole('knowledge_mgr'))
Script:
action.setRedirectURL(current);
current.workflow_state = 'review';
current.update();
Any help on this would be appreciated.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 09:17 AM
I deep dived into it and looked for this issue on the web and i think i found it. I replaced gr with some other variable name and i think it resolved the issue.
This is the article.
https://community.servicenow.com/community?id=community_question&sys_id=e61343e1dbd8dbc01dcaf3231f96190c
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 06:39 AM
GlideRecord script (I think this is all you need):
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('workflow_state', 'draft');
gr.query();
while (gr.next()){
gr.workflow_state = 'review';
gr.update();
}
https://docs.servicenow.com/bundle/london-application-development/page/script/server-scripting/concept/c_UsingGlideRecordToQueryTables.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 06:55 AM
Thanks Shane.
Got this when ran the background script. Articles are still in draft state. Any idea?
[0:00:00.676] Script completed in scope global: script
ENGINE: Workflow CommandManager.killSwitch has 1 observers
completed Begin(80abbfb4109a91c090483055ab86544c): event=update
completed Approval: Peer Review(3b9b7fb4109a91c090483055ab8654dd): event=execute
completed Saved as Draft(bb9b7fb4109a91c090483055ab8654db): event=execute
completed If Policy(ccabbfb4109a91c090483055ab865445): event=execute
ENGINE: Workflow CommandManager.killSwitch has 1 observers
completed Begin(a85c8aa6100ed98090483055ab865403): event=update
completed If the Topic is News(e45c8aa6100ed98090483055ab86549e): event=execute
completed Wait for Retired(e45c8aa6100ed98090483055ab86548e): event=execute
completed Wait for 2 Weeks(245c8aa6100ed98090483055ab865405): event=execute
*** Script: Scheduling: WFTimer4e52bfb213ede300a8e2bc122244b00c for: 11-08-18 09:52:26 AM
completed Check everyday(645c8aa6100ed98090483055ab865481): event=execute
completed Publish Article(0cabbfb4109a91c090483055ab865437): event=execute
completed Notify Author: Published(88abbfb4109a91c090483055ab86543b): event=execute
completed Delete this workflow(0cabbfb4109a91c090483055ab86544a): event=execute
completed End(8cabbfb4109a91c090483055ab86540e): event=execute
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 06:59 AM
i think it ran just for 1 article which got published. how to run it through the loop for all articles?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 07:05 AM
It should run for all the articles which are in draft. However, try running the below script.
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('workflow_state', 'draft');
gr.query();
while (gr.next()){
gr.workflow_state = 'review';
gr.setWorkflow(false);
gr.update();
}
Thanks,
Sunil Safare