Comments on: Canceling executing workflows on task closure https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/ ServiceNow Consulting Scripting Administration Development Wed, 06 Mar 2024 20:15:44 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Brad https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/#comment-6020 Fri, 24 May 2019 07:59:53 +0000 https://servicenowguru.wpengine.com/?p=407#comment-6020 Awesome, thank you.

]]>
By: Mark Stanger https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/#comment-6019 Tue, 28 Mar 2017 12:22:14 +0000 https://servicenowguru.wpengine.com/?p=407#comment-6019 In reply to Thrishna Strachan-Visser.

Awesome. I’m glad that worked!

]]>
By: Thrishna Strachan-Visser https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/#comment-6018 Tue, 28 Mar 2017 11:20:27 +0000 https://servicenowguru.wpengine.com/?p=407#comment-6018 In reply to Mark Stanger.

Changing the order to 50 did the trick. Thanks Mark!!!

]]>
By: Mark Stanger https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/#comment-6017 Fri, 17 Mar 2017 15:02:13 +0000 https://servicenowguru.wpengine.com/?p=407#comment-6017 In reply to Thrishna Strachan-Visser.

Only suggestion I can think of is to try adjusting the ‘Order’ field on your business rule. If you have a very high order it might be triggering after the workflow context is being executed. Try an order of 50 and if that doesn’t work you could try setting this up in a ‘before’ business rule.

]]>
By: Thrishna Strachan-Visser https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/#comment-6016 Fri, 17 Mar 2017 13:47:22 +0000 https://servicenowguru.wpengine.com/?p=407#comment-6016 Hi Mark,

The business rule is working for us as for as not initiating the next task in the flow is concerned. The problem I’m facing is that we have a Set Value box right after the cancellation point that is still being triggered. Do you have any suggestions on how to stop this?

My condition to cancel the workflow is state changes to Cancel. I’ve cancelled a change at a point where the following steps are
1) Set value to ZZZ
2) Create Task 123

Task 123 is not being triggered, which is exactly what I want. However, my state is being changed from Cancel to ZZZ, which is not what I want.

Any tips?

]]>
By: Shuguang Shi https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/#comment-6015 Fri, 14 Dec 2012 11:25:36 +0000 https://servicenowguru.wpengine.com/?p=407#comment-6015 In reply to Mark Stanger.

Hi Mark, indeed the syntax works fine. The reason that it didn’t work in my case is that we had another client script that makes the a field mandatory, if I just fill that field & save it, the UI action is not really executed completely. If I would trigger the UI action again, then the WF is canceled

thanks for your help!!

]]>
By: Mark Stanger https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/#comment-6014 Thu, 13 Dec 2012 12:42:05 +0000 https://servicenowguru.wpengine.com/?p=407#comment-6014 In reply to Shuguang Shi.

Yes, but my UI action only had the single workflow cancel line. I’m guessing that yours isn’t working because you’re calling your update first. Try moving ‘current.update’ after the workflow cancellation. If that still doesn’t work, then try the workflow cancellation on its own and see if you can get that to work.

]]>
By: Shuguang Shi https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/#comment-6013 Thu, 13 Dec 2012 11:09:06 +0000 https://servicenowguru.wpengine.com/?p=407#comment-6013 In reply to Mark Stanger.

Hi Mark, did you call this from a UI action? Can you let me see how your UI action script in total is done. It doesn’t work in my case. We have an UI action called Cancel Change defined on change_request table
the scrip in there looks the following

current.state=4;
current.u_change_status=6;
current.update();
new Workflow().cancel(current);
g_form.addInfoMessage(“Workflows for ” + current.getDisplayValue() + ” have been cancelled”);
action.setRedirectURL(current);

both the workflow cancel part & the InfoMessage part doesn’t work

]]>
By: Mark Stanger https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/#comment-6012 Tue, 11 Dec 2012 12:24:43 +0000 https://servicenowguru.wpengine.com/?p=407#comment-6012 In reply to Shuguang Shi.

That’s all you have to do. You’ve got the syntax correct. I just tested your code against a change request ticket in a ServiceNow demo instance and it worked correctly.

]]>
By: Shuguang Shi https://servicenowguru.com/business-rules-scripting/canceling-executing-workflows-task-closure/#comment-6011 Tue, 11 Dec 2012 12:19:35 +0000 https://servicenowguru.wpengine.com/?p=407#comment-6011 Hi Mark, you mentioned in the intro that the script include Workflow can be called also from UI action. What would be the syntax for there? I used same syntax as your example. But it didn’t work. The workflow is not canceld.
//Query for all executing workflows and cancel any running activities
new Workflow().cancel(current);
thanks in advance

]]>