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

# Condition Node

> Control workflow execution using JavaScript-based conditional logic in DotPortion.

# Condition Node

The **Condition Node** allows you to control **whether a workflow continues execution** based on a condition written as a **JavaScript expression**.

It enables **branching logic** similar to `if` statements in traditional programming.

***

## What the Condition Node Does

The Condition Node is responsible for:

* Evaluating a JavaScript expression
* Deciding whether the workflow should continue
* Enabling conditional execution paths

If the condition evaluates to **true**, execution continues to the next connected node.\
If it evaluates to **false**, the workflow stops or follows an alternate path (if configured).

***

<img src="https://mintcdn.com/dotportion/RvUelfRuZ_AGwzZr/images/nodes/condition.png?fit=max&auto=format&n=RvUelfRuZ_AGwzZr&q=85&s=4ac658608ed0f4599ad864b95cfbf1f8" alt="Condition" width="834" height="900" data-path="images/nodes/condition.png" />

## Configuration

### Condition

The **Condition** field accepts a **JavaScript expression** that must evaluate to either `true` or `false`.

You can reference data from previous nodes using **dynamic values**.

> Tip: Type `{{` to insert values from earlier nodes.

***

## Writing Conditions

Conditions are written as **pure JavaScript expressions**.

### Examples

#### Check a boolean value

```js theme={null}
{{parameters.isCompleted}} === true
```

#### Check if a value exists

```javascript theme={null}
{{parameters.title}} != null
```

#### Compare numbers

```javascript theme={null}
{{order.total}} > 1000
```

#### String comparison

```javascript theme={null}
{{user.role}} === "admin"
```

***

## Using Dynamic Values

Dynamic values come from:

* Request Parameters Node
* Logic Node
* Database Node
* JWT Node

They are injected using the `{{ }}` syntax.

Example:

```javascript theme={null}
{{params.userId}} !== undefined
```

***

## Execution Behavior

* Condition is evaluated at runtime
* Expression must return `true` or `false`
* If `true` → workflow continues
* If `false` → workflow stops or exits the current branch

***

## Common Use Cases

* Input validation
* Role-based access control
* Conditional database writes
* Feature flags
* Guard clauses (fail fast)

***

## Example: Validate Required Input

```javascript theme={null}
{{parameters.title}} && {{parameters.description}}
```

Only continues execution if both values are present.

***

## Error Handling

If the condition:

* Throws an error
* Returns a non-boolean value

The workflow fails and an error response is returned.
