---
id: scripting-decision-conditions
title: "Decision conditions"
summary: "Route records to branches with the Decision router. Write GetRoute in C#, return a route name, and set the same route id on the outgoing connections."
audience: user
keywords: "decision, router, condition, GetRoute, route id, branch, if, switch, else"
---
# Decision conditions

The **Decision router** sends each record down one branch of the flow. You write a short C# method that returns a
route name; the record goes to the connections whose **Route Id** is that name.

## Write the condition

```csharp
public string GetRoute(IMetaData metaDataInstance, IViaType inputDataInstance)
{
    var metaData = (viauser.FlowMetaData)metaDataInstance;
    var inputData = (viauser.Order)inputDataInstance;
    if (inputData.Amount > 1000) return "Large";
    return "Small";
}
```

The template casts the input to the type of the input connection. The `Services` property gives you the
[flow services](./services), and the flow's NuGet packages are available.

## Draw the branches

1. Draw one connection from the router's `Output` for each branch.
2. Select a connection and set its **Route Id** in the connection properties: `Large`, `Small`.
3. Switch on **Show route** to see the route id on the canvas.

## How records are routed

- The returned name is compared with each route id exactly, including case.
- A record whose name matches no connection is dropped.
- A connection without a route id receives every record.

For an "else" branch, return an explicit name such as `"Other"` and give a connection that route id.

The condition runs for every record. Keep it fast and free of side effects.
