# While

The While action node runs a block of action nodes as long as a condition evaluates to true.

## Usage

This action node is an iterator. It is used to continuously loop over one or more action nodes *while* a condition is true. The action nodes to be run are placed inside the While action node.

This action node is suited to cases where you have a fixed number of iterations that you wish to run, or when the total number of iterations is unknown.

When the action node is first run, the condition is evaluated. If the condition evaluates to true, the action nodes placed inside the iterator are run. The condition will then we re-evaluated and continue as such. If the condition evaluates to false, the iterator terminates and the next action node (if any) will be run.

{% hint style="warning" %}
**Important**

One of the action nodes inside the iterator should affect the condition to ensure that it does at some point evaluate to false and the iterator can terminate.
{% endhint %}

{% hint style="info" %}
**Example**

A While example is available in our [Showroom](https://showroom.appfarm.app/action-nodes/while). You can view the demo, as well as access the setup in Appfarm Create. Don't have access? [Register](https://showroom.appfarm.app/sign-up).
{% endhint %}

## Properties

<table><thead><tr><th width="195">Property</th><th>Description</th></tr></thead><tbody><tr><td><strong>Condition</strong></td><td>Define a condition that will be evaluated before each iteration. The condition must evaluate to true for the action nodes inside the iterator to run. When the condition evaluates to false, the action will move on to the next action node.</td></tr></tbody></table>


---

# 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.appfarm.io/library/action-nodes/while.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.
