Abort workflow

workflow
studio

#1

I have main and child wokflow. I would like to stop wokflow for some condition in child workflow. I am trying it using stop workflow but it’s continuing to main workflow activities that i don’t want.
Please find atached workflowWorkflowTermination1.zip (438.5 KB)


#2

This is something you could approach in several ways, depending on what the child workflow does and how the main workflow should stop. Unfortunately your attached file contains just one workflow, so I can’t see what your intent is, but I would consider the following:

  • Is the condition exceptional? For example, a workflow expects some crucial UI element but it is not present, or an extracted string of text is empty where it must not be for the workflow to make sense. In cases like these it’s sensible to throw exceptions and/or, if using Orchestrator, mark a transaction as failed, because you want to be alerted and possibly adapt your workflow. The Throw activity can be used with an Exception type of your choice, or the Terminate Workflow activity with a Reason string, to throw a new exception, immediately ending execution unless caught at some point by a Try Catch.
  • The condition could also be unexceptional, for example a workflow checks for new files in a directory or new mail messages but none are found. In such cases it makes more sense to, for example, let a child workflow return an empty array and in the main workflow use a Decision to check for this, only connecting further activities to the appropriate path. The workflow then stops there in the other case, or you could connect this to a generic ending sequence where you log this result, close some applications, etc. It is necessary here, but also recommended in general, to use a Flowchart for the main workflow.

More on Exceptions can be found in Lesson 12 of the Academy Foundation training. More on throwing/catching exceptions on the forum:


#3

Hello,
Please find the right workflow file.
WorkflowTermination.zip (443.8 KB)

I am doing some validations in child workflow ; based on some business rules if it failed, then i would like to abort complete process, i don’t want to continue any activity in parent workflow in this case. Process can be abort multiple places in child workflow based on rules. I don’t want any termination popup.


#4

Try something like this:
WorkflowTermination.zip (444.6 KB)


#5

Thank you for suggesting workaround. but do we have any other better solution? what about if we have multiple places in child workflow where we can have exception?
I would like to terminate process in called workflow rather then return to main worfkow and then add decesion box etc.


#6

Well, you can just have multiple If activities in the child workflow where you conditionally raise an exception. You cannot do something like your second suggestion, because the invoked (child) workflow should be viewed as a function: it either returns succesfully, after which execution resumes in the workflow where it was called, or it throws an exception, which will terminate also any calling workflows unless it is caught by them. Furthermore, a Sequence activity will always complete all inner activities unless an exception occurs, whereas a Flowchart can additionally terminate normally at a Decision or Switch.