Conditions¶
Conditions act as guards or filters in an ECA model. They determine whether a particular path of actions should be executed. If a condition evaluates to TRUE, the connected actions proceed; if FALSE, that branch is skipped.
What is a condition?¶
A condition is a yes-or-no check applied to a connection between components in your model. It answers the question: "Should this path be followed?"
Conditions do not perform any changes themselves -- they only evaluate a situation and return TRUE or FALSE. This makes them safe to use: a condition never modifies data.
Common condition types¶
ECA offers a wide range of conditions. Some of the most frequently used include:
- Scalar comparison
- Compare two values (equal, not equal, greater than, less than, contains, etc.). Useful for checking field values, token contents, or any text/number comparison.
- Entity type and bundle
- Check whether an entity is of a specific type (e.g. node, user) or bundle (e.g. article, page). Essential when an event applies to multiple content types but you only want to act on one.
- User role
- Verify whether the current user has a specific role. Commonly used to restrict actions to administrators or specific user groups.
- Entity field value
- Check whether a specific field on an entity has a particular value, is empty, or matches a pattern.
- Route match
- Evaluate the current Drupal route or path, useful for request/response event models.
Browsing available conditions
The full list of conditions depends on which modules are installed. See the Plugins section for a complete reference, organised by module.
Negating conditions¶
Every condition in ECA can be negated. When you negate a condition, the logic is inverted: a condition that would normally return TRUE returns FALSE instead, and vice versa.
This is useful when you want to express "if NOT this condition" without needing a separate condition plugin. For example, negating a "user has role" condition effectively becomes "user does NOT have role".
Combining conditions (AND / OR logic)¶
You can combine multiple conditions on different connections leading from the same component:
- AND logic: Attach multiple conditions to the same connection (or chain conditions in sequence). All must be TRUE for the path to proceed.
- OR logic: Create separate connections from the same source to the same target, each with a different condition. If any one connection's condition is TRUE, the target action executes.
For more complex conditional branching, consider using gateways.
Adding conditions to a model¶
Conditions are not standalone components that sit on the canvas on their own. Instead, they are attached to the connections (edges) between events, actions, and gateways. This is an important distinction that newcomers often find surprising.
Workflow Modeler¶
- First, ensure you have an event and at least one action connected by an edge.
- Click on the edge (the line connecting two components).
- In the side panel, add a condition by selecting from the available condition types.
- Configure the condition's settings (comparison values, fields to check, etc.).
- Optionally enable Negate to invert the condition logic.
You can also use the Quick-Add feature: when adding a successor from a node, the popup allows you to insert a condition on the new edge directly.
BPMN.iO¶
- Draw a sequence flow (arrow) from an event or action to the next element.
- Click on the sequence flow arrow.
- In the configuration panel on the right, select a condition from the dropdown.
- Configure the condition's settings.
- Optionally enable negation.
Note
In BPMN terminology, a condition on a sequence flow is called a "conditional flow". The condition determines whether the flow is followed.
Classic Modeler¶
- When connecting components, the form interface provides a field for adding conditions.
- Select the condition type and configure its parameters.
- Use the negate option if needed.
Tips for working with conditions¶
- Conditions go on connections, not nodes: This is the most common point of confusion for new users. You do not add a condition as a separate box on the canvas. Instead, you attach it to the arrow/edge between two components.
- Keep conditions simple: If a condition requires complex logic, consider breaking it into multiple simpler conditions or using custom events to separate concerns.
- Use negation wisely: Rather than creating a separate "is not" condition, negate the existing one.
- Test conditions with debugging: Use the debugging tools to verify that conditions evaluate as expected. The logs show which conditions passed and which were skipped.
- Mind token availability: Conditions often reference tokens. Ensure the token you are checking has been made available by the event or a preceding action. See Tokens.