# Conditions and waits

> Choose which path a workflow takes with rules, splits and loops, and when each step runs with waits.

Source: https://docs.komplian.com/flows/conditions

Where: Flows → your workflow → Control Flow
Who: Owners, admins and managers edit workflows.
Plan: Growth+

Control steps sit between the trigger and the actions. They decide which path each run follows and how long it waits before the next step.

## Add a control step

### 1. Drag the step
In the builder, drag a step from **Control Flow** onto the canvas.

### 2. Connect its exits
Connect each exit of the step, for example **Yes** and **No**, to the step that should follow it.

### 3. Write the rules
Click the step and fill its settings. A step with no rules shows **Add at least one rule**.

## Decide the path

| Step | What it does | Exits |
| --- | --- | --- |
| **Condition (If/Else)** | Checks the rules and sends the run one way or the other. | **Yes** when the rules match, **No** when they do not. |
| **Filter** | Lets the run continue only if the rules match. Otherwise the run ends there. | One. |
| **Switch** | Picks a path by the value of one field. Under **Cases**, add one case per value. | One per case, plus **Default** for any other value. |
| **A/B Split** | Splits runs between variants by percentage. The percentages must add up to 100%. | One per variant. |

Compare the variants of an **A/B Split** under **A/B test** in the flow's [results](https://docs.komplian.com/flows/overview#read-the-results).

## Write a rule

A rule compares a field with a value, for example **Order Total** **Greater than** 100.

### 1. Pick the field
Choose the **Field**, such as **Contact Email** or **Lead Status**.

### 2. Pick the operator
Choose the **Operator** from the table below.

### 3. Write the value
Write the **Value** to compare with. **Is empty** and **Is not empty** need no value.

### 4. Combine rules
Press **Add rule** for more. Under **Match**, choose **All rules (AND)** or **Any rule (OR)**.

| Group | Fields you can use |
| --- | --- |
| Contact | **Contact Name**, **Contact Email**, **Contact Phone**, **Contact Company** |
| Lead | **Lead Status**, **Lead Source**, **Lead Value** |
| Order | **Order Total**, **Order Currency**, **Item Count** |

| Operator | Matches when the field |
| --- | --- |
| **Equals** | Is exactly the value. |
| **Not equals** | Is anything but the value. |
| **Greater than** / **Less than** | Is a number above or below the value. |
| **Greater or equal** / **Less or equal** | Is a number at or above, or at or below, the value. |
| **Contains** / **Does not contain** | Includes or does not include the text. |
| **Starts with** / **Ends with** | Begins or ends with the text. |
| **Is empty** / **Is not empty** | Has no value, or has one. |

## Decide the timing

| Step | What it does | Settings |
| --- | --- | --- |
| **Delay (Wait)** | Waits a fixed time before the next step. | **Wait Duration** and **Unit**: **Minutes**, **Hours** or **Days**. |
| **Wait Until** | Waits for a date and time. | **Wait until (date & time)** and **Max wait (hours)**. |

A run that is waiting counts as **In progress** in the results. **Test this flow** skips every wait; **Run this flow now** keeps them.

## Repeat steps with a loop

**Loop** runs the steps on its first exit once for each item of a list. When the list ends, the run continues on its second exit.

| Setting | What it does |
| --- | --- |
| **List Variable** | The list to go through, for example `order.items`. |
| **Max iterations** | The most times the loop runs, whatever the length of the list. |

Inside the loop, `{{loop.item}}` is the current item and `{{loop.index}}` is its position.

## Related

- [How flows work](https://docs.komplian.com/flows/overview): Build, test and publish a workflow.
- [Triggers](https://docs.komplian.com/flows/triggers): What starts the workflow.
- [Actions](https://docs.komplian.com/flows/actions): What each path does.
