Using the TerminateWorkflow Activity to Stop a Workflow Job

Follow

To terminate a Workflow Job at a specific time and throw a specific exception, you can use the Terminate Workflow activity. The TerminateWorkflow activity immediately ends the Workflow Job with the specified exception and a Final Severity of "Error".

The TryCatch activity in the Workflow can be used to catch an exception created by another activity. For more control of the final output, use the TerminateWorkflow activity in the Catches section of the TryCatch block and provide a custom reason.

TerminateWorkflow Activity Properties

 Property Description
DisplayName

Enter the text that is displayed for the TerminateWorkflow activity within the Workflow Job.

Exception

Enter the exception to end the Workflow Job. The exception is displayed in the log file from the Monitor view.
Examples:

  • new System.Exception("Failed Due to xyz")
  • new System.NotSupportedException()
  • new System.NotImplementedException()

NOTE: The exception must be fully qualified using the System namespace.

For additional information on common exception types and when to use them, see the Exception Class article.

Reason

Enter the text that will be displayed in the Description field in the Monitor view. It is also displayed as the final status in the log file from the Monitor view.

Adding a TerminateWorkflow Activity to a Workflow Job

  1. Click Definitions from the Shortcuts menu.
  2. Right-click the Workflow Job and select Properties.
  3. Click the Source tab.
  4. Under the Toolbox, expand the Runtime section.
  5. Drag and drop the TerminateWorkflow activity onto the Activity panel.
    Workflow_terminate_activity.png
  6. In the Properties panel, enter values for the exception and reason.
    Workflow_terminate_activity_reason.png
  7. Click Save and Close.

Viewing the Terminated Workflow Job

After the Workflow Job runs, you can view the reason and the exception.

  1. Run the Workflow Job.
  2. Click Monitor from the Shortcuts menu.
  3. View the Reason in the Description field in the Monitor view.
  4. Double-click the Workflow Job.
  5. Click the Log File tab.
  6. View the reason and the exception values in the log.
    Workflow_log_file.png
  7. Close the window.

 

Have more questions? Submit a request

Comments