The CreatorCon Call for Content is officially open! Get started here.

How to invoke UI Action using background or fix script.

dvelloriy
Kilo Sage

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.

find_real_file.png

 

2. When we click on "Submit for review".

find_real_file.png

 

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.

1 ACCEPTED SOLUTION

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

View solution in original post

12 REPLIES 12

Well, you're basically doing what was offered up here:

https://community.servicenow.com/community?id=community_question&sys_id=927503eddbd8dbc01dcaf3231f961932

Which worked there.

 

Have you tried doing to manually via the list view, as they suggest at that link?  I'd probably put in a HI ticket to see if they can determine why that script isn't working.

it's disabled through list view. Actually, we we click on "Submit for review", it first changes the state from draft to review and then in turns triggers the workflow which publish it and deletes the workflow at the end, This is what i get when i run the back ground script:

I am not sure why it is just running for 1 article though. 

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

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