- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 06:36 AM
Hi All,
I've created a new workflow for a catalog Item. The Catalog item has 5 checkbox variables. Each checkbox decides if a task is generated. We have scenarios however that once the ITEM has been submitted we might need to manually create further tasks.
I've created a wait condition script to check all tasks are closed before moving to a run script to close the ITEM.
For example If 2 checkboxes on the catalog item were true, 2 tasks get generated. We then manually create a 3rd task.
If the manually created task is closed before either of the workflow generated tasks the workflow works fine.
If the manually created task is the last task to be closed the workflow remains stuck at the wait condition. If I then go into the workflow context and 'nudge' the workflow, the wait condition runs and the workflow completes.
Is there a way to amend the workflow or some other means to get the workflow to complete without having to manually nudge the workflow?
Below is the workflow and the wait condition script:
Any help is greatly appreciated
Thanks
Sam
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 09:37 AM
Hi Andrii,
Thanks for all your help on this. I have managed to get this working following trawling through many articles on here. one had a link to the following:
Condition Activities - ServiceNow Wiki
section 4.4 example script got this working.
Thanks
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 06:42 AM
Wait condition always triggers when records is updated. Therefore you have to fire update operation on your RITM when tasks changing their state.
There is a fake update operation that would trigger your workflow:
var ritm = new GlideRecord('sc_req_item')
ritm.get();
ritm.setWorkflow(false);
ritm..setForceUpdate(true);
ritm.update();
so you may need to create a business rule that would be fired on update operation of catalog tasks table that would do this to your ritm workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 07:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 07:56 AM
In your particular case I would recommend to make this "after" (not" before") Business Rule. and in order to troubleshoot - try removing condition "State is changing". and remove setWorkflow(false) - I think I added it automatically.
So your code would be like this:
...
ritm.get();
ritm.setForceUpdate();
ritm.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 08:06 AM
Hi Andrii,
Thanks for the above, I've made the above changes, but the RITM is remaining open if I close the manually created task last.
I have seen the OOTB there is the business rule 'SNC - Run parent workflows'.
Do you know why this does not trigger the workflow and if this needs amending in some form?
Thanks
Sam
