Elsa 3.0 Help

Outcomes

In Elsa, activities are connected to form a flowchart that defines the logic of the workflow. Each activity can have multiple potential results, which are referred to as outcomes. These outcomes serve as "ports" that dictate the next step in the workflow based on the result of the activity. This powerful mechanism simplifies workflows by eliminating the need for separate decision activities to evaluate an activity's result.

What is an Outcome?

An outcome in Elsa is a possible result of an activity's execution. Once an activity completes, the workflow can continue down different paths depending on which outcome was produced. For instance, an approval activity might have two outcomes: "Approved" and "Rejected." By connecting these outcomes directly to other activities in the workflow, users can control the flow without the need for intermediate decision activities.

How to Use an Outcome?

Outcomes are exposed as "ports" or connectors from one activity to the next. When defining a workflow, you can simply connect an activity's outcome to the next relevant activity in the flowchart. This provides a visual and intuitive way of representing decision logic.

For example:

  • A "Send Email" activity might have two outcomes: "Success" and "Failure."

  • Depending on the outcome, you could connect "Success" to a "Log Activity" and "Failure" to a "Retry" activity.

Outcomes in Nested Workflows

Workflows can be used as activities within other workflows, and they too can define their own outcomes. When creating a workflow that you plan to use as a nested activity inside another workflow, you can define its outcomes to represent different execution paths. This allows parent workflows to continue based on the outcome of the nested workflow, offering modularity and flexibility in complex scenarios.

Difference Between an Outcome and an Output

While both outcomes and outputs represent information produced by an activity, they serve different purposes:

  • Outputs: These are data or results generated by an activity that can be used later in the workflow. Outputs allow activities to pass values (such as a number, string, or object) to subsequent activities for processing or storage.

  • Outcomes: These define the flow of the workflow itself, determining which path to follow based on how the activity completes. Instead of providing data, outcomes shape the control flow by specifying which activity should run next.

For instance, a "Form Submission" activity might have an output containing form data (e.g., the values entered by the user), while its outcome might determine whether to send a confirmation email or display an error message depending on whether the form validation was successful or not.

Benefits of Using Outcomes

  • Simplification of Flow Logic: By using outcomes, workflows become more streamlined since there is no need for decision nodes to handle activity results.

  • Visual Clarity: The flowchart clearly shows which path follows from each possible outcome, making it easier to understand at a glance.

  • Modularity: Workflows and activities can be reused more easily when outcomes are well-defined, enabling a flexible and scalable workflow design.

In summary, outcomes in Elsa Workflows provide a simple and effective way to direct the flow of your workflows based on how activities conclude. By distinguishing between outcomes and outputs, users can manage both the logical flow and the data flow in their workflows with clarity and ease.

Last modified: 21 September 2024