- 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 07:08 AM
I'd try that on one article before doing more:
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('workflow_state', 'draft');
gr.addQuery('sys_id', 'get_an_articles_sys_id');
gr.query();
while (gr.next()){
gr.workflow_state = 'review';
gr.setWorkflow(false);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 07:05 AM
The 'while' is supposed to do that if the query is correct. Can you go to a List View of the articles you want this to apply against, and then 'copy query' from the breadcrumb and post it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 07:15 AM
This is the query.
sys_created_onON2018-10-26@javascript:gs.dateGenerate('2018-10-26','start')@javascript:gs.dateGenerate('2018-10-26','end')^workflow_state=draft
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 07:20 AM
OK, try:
var gr = new GlideRecord('kb_knowledge');
//gr.addQuery('workflow_state', 'draft');
gr.addEncodedQuery('sys_created_onON2018-10-26@javascript:gs.dateGenerate('2018-10-26','start')@javascript:gs.dateGenerate('2018-10-26','end')^workflow_state=draft');
gr.query();
while (gr.next()){
gr.workflow_state = 'review';
gr.update();
}
Though I don't see anything there that should cause it to run any differently.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2018 07:37 AM
Same result 😞