Steve0

How to Cancel a Workflow if it's Already Running?

Discussion created by Steve0 on Feb 17, 2016
Latest reply on Mar 15, 2016 by Steve0
I have a workflow which is on a schedule to run every hour on the hour, this workflow will process customer orders and some days we will have a lot of orders which may require more than an hour to process. So what I'm looking for is, if that workflow is already running and the schedule starts another instance of that workflow then I want the second workflow to see that it's already running and to abort the second one while not interpreting the first running workflow. 

The last task in the workflow will loop back to the first task and if there is any work available (Any files in the /unprocessed_emails DIR) then it will continue to run, else it will abort and wait another hour to be kicked off by the scheduler. 

I've taken 2 approaches with no luck.. 

1st Approach 

I went into the attributes tab of the workflow, selected 'Generate at Runtime', put the 'Max Parallel Tasks = 1' and checked the 'Abort' radio button. The problem I have with this is that after running through 1 entire workflow, it will automatically abort due to the conditions set in the attributes tab. 

2nd Approach 

I then tried to edit the Pre-Conditions tab of the first task and selected 'Check Activities' IF my workflow = 2 ANY_ACTIVE then Cancel Process Flow -- ELSE Run Task.. This did not work either because the second task will show up in the activities window for 1-2 seconds showing as ACTIVE before it executes which will block/abort the workflow 









Outcomes