> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/library/action-nodes/switch.md).

# Switch

The Switch action node evaluates an expression once and runs the first Case whose value matches. Switch is available in [flows](/reference/flows.md).

## Usage

A Switch is a chain of linked Case nodes that share a single expression. The first node in the chain holds the expression and is also the first Case. Each following node adds another Case.

When the Switch runs, the expression is evaluated once and compared against each Case in order. The first Case whose value equals the expression runs its block of action nodes. The remaining Cases are skipped.

A Case with no Value configured is the Default. The Default runs when none of the other Cases match. A Switch chain does not need a Default — if no Case matches and there is no Default, the Switch does nothing and execution continues with the next action node after the chain.

Each block in the chain has controls to move it up or down, or add a new Case after it. The first node in the chain is pinned at the top and cannot be moved.

{% tabs %}
{% tab title="Example: Route on order status" %}
A flow updates orders received from an integration. Each order arrives with a `Status` enum that can be `New`, `Paid`, `Shipped`, or `Cancelled`. The flow uses Switch on the `Status` property to run a different block for each status, with a Default block that logs unknown values.

<figure><img src="/files/BCZGjLgYLOIvOjCy1YKC" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## Matching

Cases are matched using strict equality. The data type of the Case value must match the data type of the expression — `"1"` does not match `1`.

The expression must be a data binding to a property of one of these types:

* [Enum](/reference/data-model/enumerated-types.md)
* String
* Integer
* Float
* Boolean

Constants, functions, conditions, null, and [value processors](/reference/platform-concepts/value-processor.md) are not available on the expression.

Each Case value is entered as a constant, and its data type is locked to the data type of the expression. For an Enum expression, the value picker on each Case shows the options of the referenced enum.

{% hint style="info" %}
**Good to know**

Case values are matched against the expression with strict equality, and the data type of each Case value is locked to the data type of the expression. This means a Case configured for an Integer expression cannot be set to the string `"1"` — the value picker enforces the type.
{% endhint %}

## Exception handling

A [Catch Exception](/library/action-nodes/catch-exception.md) action node placed inside a Case behaves the same way as in any other block. It catches exceptions thrown by action nodes inside that Case.

## Properties

The **Expression** property is set on the first node in the chain. The **Value** property is set on each following Case.

| Property       | Description                                                                                                                                                                              |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Expression** | *Set on the first node in the chain only.* A data binding to the property whose value is compared against each Case. The property must be one of: Enum, String, Integer, Float, Boolean. |
| **Value**      | The value the Case is matched against. The data type is locked to the data type of the **Expression**. Leave **Value** unset to make the Case the Default.                               |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.appfarm.io/library/action-nodes/switch.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
