# How to Use the Loop Rule with Exit Condition in Reels

**URL:** https://community.neutrinos.com/t/how-to-use-the-loop-rule-with-exit-condition-in-reels/843
**Category:** Training, Academy & Certifications
**Tags:** neutrinos-reels
**Created:** [June 13, 2025, 8:57am UTC](https://community.neutrinos.com/t/how-to-use-the-loop-rule-with-exit-condition-in-reels/843 "2025-06-13T08:57:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Rocky](https://community.neutrinos.com/user_avatar/community.neutrinos.com/rocky/32/1473_2.png) [@Rocky](https://community.neutrinos.com/u/Rocky)
#### Post date: [June 13, 2025, 8:57am UTC](https://community.neutrinos.com/t/how-to-use-the-loop-rule-with-exit-condition-in-reels/843/1 "2025-06-13T08:57:29Z")

</div>

**Hi Team,**

This post explains how to configure and use the **Loop Rule with an Exit Condition** in **Reels** to iterate over a list of names and stop processing when a specific condition is met.

* * *

### 📘 Use Case

The objective is to:

- Iterate through an array of name objects.
- Terminate the loop when the name `"Rakesh"` is found.
- Return a Boolean flag (`true`) once the condition is satisfied.

* * *

### 🧱 Step-by-Step Configuration

#### 🔹 1. **Script Node**

We begin with a `SCRIPT` rule that defines a static array of objects:

```auto
OP_out = [
  { "name": "Sinan" },
  { "name": "Rakesh" },
  { "name": "Fawaz" }
];

```

📌 **Global Output Mapping:**

- Output key: `Scriptoutput`
- Mapped from the script’s output field: `out`

* * *

#### 🔹 2. **Loop Rule Setup**

**Loop Configuration:**

- **Sequence Field** : `Scriptoutput` (the array defined in the script)
- **Sequence Type** : `Array of Objects`
- **Output Type** : `Object`

**Loop Input Mapping:**

- `name` → Maps to the `name` field of each object in the sequence

**Loop Output Mapping:**

- `status` → Captures whether the loop condition has been met (`true` or `false`)

📌 **Global Output Mapping:**

- Map `status` (loop output) to global key `Loopoutput`

* * *

#### 🔹 3. **Decision Table Rule (Inside Loop)**

A **Decision Table** is used within the loop to determine when to exit. The condition is defined as follows:

| Condition (`name`) | Result (`status`) |
| --- | --- |
| Equals `"Rakesh"` | `true` |
| Default | `false` |

📌 This `status` flag is evaluated after each iteration.

* * *

#### 🔹 4. **Exit Condition in Loop**

The Loop Rule is configured with the following **exit condition** :

```auto
status == "true"

```

✅ As soon as this condition is met (i.e., `name == "Rakesh"`), the loop stops.

* * *

### ✅ Final Output

After successful execution, the output will appear as:

```auto
{
  "script out": [
    { "name": "Sinan" },
    { "name": "Rakesh" },
    { "name": "Fawaz" }
  ],
  "loop output": "true"
}

```
