TerminateWorkflow

Estimated reading: 3 minutes 1488 views

This activity is used to abruptly stop the execution of the current workflow. It essentially acts as a mechanism to forcefully end the workflow at a specified point, terminating the execution of any activities that come after it in the workflow sequence. It is commonly employed to handle exceptional situations or to intentionally stop the workflow under specific conditions.

Properties

MISC

Display Name: Displays the name of the activity. The activity name can also be customized to help in troubleshooting.

Exception: This parameter indicates to provide the exception message to abort the workflow. You have the option either to hardcode the values or input values.

Reason: Indicates to specify the reason for the exception to abort. By default, it will be blank. This parameter accepts only “String” datatype.

Example

The following activity illustrates on how we will use the terminate workflow activity to terminate a workflow when an exception occurs.

In this example, we will design a simple workflow to demonstrate how to terminate it when a system exception occurs. The Terminate Workflow activity can be used to handle both business and system exceptions effectively.

Let’s create a workflow using the Element Exists activity within a Try-Catch activity to observe how the bot handles errors and terminates the workflow when an exception occurs.

Steps to Create the Workflow:

1. Drag and drop a Sequence activity from the Control Flow feature.
2. Inside the sequence, add a Try-Catch activity.
3. In the Try segment, place an Element Exists activity:
4. Double-click on the activity to configure it.
5. Spy for an element on a webpage to be found. For this example, let’s spy the “Google” element on the Google homepage.
6. In the Catches segment – Add a System.Exception type.
7. Specify the next action the bot should perform when an error occurs.
8. Add a Message Box activity in the Catches segment to display the error:
9. Set a title for the message box (e.g., “Error Occurred”).
10. In the input string field, use the exception.Message property to display the error details.
11. Below the message box, add a Terminate Workflow activity to stop the workflow execution.
a. In the Reason field of the activity, provide a message explaining the termination cause. For example: “The Google page was closed or not found.”
12. Workflow Execution:
If an exception occurs: The bot will throw an error message via the message box, display the specified termination reason, and terminate the workflow.
If no exception occurs: The bot will continue to the Finally segment and display a message indicating the successful execution of the workflow.

Share this Doc

TerminateWorkflow

Or copy link

CONTENTS