# Each

### Overview

The **Each Component** iterates over a list and outputs a new message for each item. It allows processing list elements individually, enabling sequential execution of subsequent actions.

### Usage

#### Input Parameters

| Parameter | Type               | Description                                                                       |
| --------- | ------------------ | --------------------------------------------------------------------------------- |
| `list`    | `array` / `string` | The list to iterate over. If a string is provided, it must be a valid JSON array. |

#### Input Ports

| Port | Description                        |
| ---- | ---------------------------------- |
| `in` | Receives the list to iterate over. |

#### Output Ports

| Port   | Description                                                                              |
| ------ | ---------------------------------------------------------------------------------------- |
| `item` | Emits each item from the list with additional metadata.                                  |
| `done` | Fires after all items have been processed, providing the total count and correlation ID. |

#### Output Data for `item` Port

| Field           | Description                                      |
| --------------- | ------------------------------------------------ |
| `index`         | The index of the current item in the list.       |
| `value`         | The value of the current item.                   |
| `count`         | Total number of items in the list.               |
| `correlationId` | Unique identifier for tracking batch processing. |

#### Output Data for `done` Port

| Field           | Description                                     |
| --------------- | ----------------------------------------------- |
| `count`         | The total number of processed items.            |
| `correlationId` | Unique identifier for tracking batch execution. |

### Instructions

1. **Provide a List**
   * Ensure the input `list` is an array or a valid JSON string representing an array.
2. **Processing Items**
   * Each item in the list is sent separately to the `item` port.
   * The `done` port is triggered after all items are processed.
3. **Handling Index and Correlation ID**
   * Each item is assigned an `index` and a `correlationId` to track processing.

### Notes

* **Supports JSON Parsing**: If `list` is a string, it will attempt to parse it as JSON.
* **State Persistence**: Keeps track of progress and resumes processing if interrupted.
* **Efficient for Iteration**: Useful for batch processing workflows requiring individual handling of list elements.


---

# Agent Instructions: 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:

```
GET https://docs.appmixer.com/connector-configuration/utils/controls/each.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
