> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yorlet.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Conditions and loops

> Branch a workflow with If / else, or repeat steps for every item in a list with For each.

Logic steps sit alongside actions on the canvas. Click **Add step**, then choose **If / else** or **For each** from the **Logic** group.

## If / else

**If / else** branches the workflow. Steps on the **Yes** path run when the conditions pass. Steps on the **No** path run when they do not.

To add a condition, follow these steps:

1. Click **Add step** and choose **If / else**.
2. Select the step. In the side panel, set **Match**:
   * **All conditions must pass** — every row must be true (and).
   * **Any condition can pass** — one true row is enough (or).
3. Click **Add** to create a condition row.
4. Enter the left value, choose an operator, and enter the right value when the operator needs one. Both sides can be a literal or a `{{ }}` expression.
5. Click **Add step** on the **Yes** or **No** branch to add the steps that should run on that path.

If you add no conditions, the workflow always follows the **Yes** branch.

### Operators

| Operator                  | When it passes                                                |
| ------------------------- | ------------------------------------------------------------- |
| **Equals**                | The two values are the same.                                  |
| **Does not equal**        | The two values are different.                                 |
| **Greater than**          | The left value is greater than the right.                     |
| **Greater than or equal** | The left value is greater than or equal to the right.         |
| **Less than**             | The left value is less than the right.                        |
| **Less than or equal**    | The left value is less than or equal to the right.            |
| **Contains**              | The left value includes the right value.                      |
| **Does not contain**      | The left value does not include the right value.              |
| **Is empty**              | The left value is missing or blank. No right value is needed. |
| **Is not empty**          | The left value has a value. No right value is needed.         |

<Tip>
  A typical pattern is a **Database event** trigger for `invoice.paid`, then an **If / else** that checks `{{ trigger.object.total }}` is **Greater than** a threshold, with a **Create task** on the **Yes** branch.
</Tip>

## For each

**For each** repeats the steps on its **Each item** branch once per item in an array, then continues along the **Then** branch.

To add a loop, follow these steps:

1. Click **Add step** and choose **For each**.
2. Select the step and set **Array** to an expression that resolves to a list, for example `{{ trigger.object.customers }}`.
3. Click **Add step** on the **Each item** branch and configure the steps to run for every item.
4. Optionally add steps on the **Then** branch to run after the loop finishes.

Inside the **Each item** branch you can insert:

* `{{ loop.item }}` — the current item
* `{{ loop.item.id }}` — the current item's ID, when the item is a record
* `{{ loop.index }}` — the current item's position, starting at 0

<Note>
  A loop can run for at most 50 items. If the array is longer, the run fails.
</Note>

<Tip>
  Use **For each** when a trigger has a list of people — for example granting loyalty points to every customer on a tenancy, with **Recipient** set to `{{ loop.item.id }}`.
</Tip>
