> For the complete documentation index, see [llms.txt](https://docs.ondeva.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ondeva.com/workflow/steps-reference/logic.md).

# Logic

The **Logic** category enables decision-making, control flow, and integration within workflows. These steps are used to create dynamic, reactive applications that can branch, loop, or integrate with external systems — without writing a single line of backend code.

### **Check Condition (If / Else)**

**Purpose:**

Evaluates one or more conditions and executes different branches of the workflow based on the result (true or false).

**Key Options:**

* **Logic Operator**: `AND` / `OR` — controls how multiple conditions are combined.
* **Conditions**: Define comparisons using left-hand value, operator, and right-hand value (e.g., `user.age > 18`).
* **Invert Result**: Flips the result of the condition (true becomes false, and vice versa).

**Outputs:**

* Two required outputs: one for the **true** branch, one for the **false** branch.

**When to Use:**

* Gate logic based on user roles, values in a form, or backend response.
* Control what happens next depending on whether conditions are met.

***

### **Execute Workflow**

**Purpose:**

Calls another existing workflow (sub-workflow), allowing you to modularize logic and reuse workflows.

**Key Options:**

* **Workflow Selector**: Choose any existing workflow from your app.

**When to Use:**

* To reduce repetition by reusing logic across workflows.
* When creating a "parent" workflow that delegates subtasks.
* For clean separation of logic (e.g., “Send email”, “Log event”, “Sync CRM”).

***

### **For Each**

**Purpose:**

Loops over a list (table, array, query result) and executes a workflow for each item.

**Key Options:**

* **Workflow**: The workflow to execute for each item.
* **Variable**: The list or table to iterate through.
* **Async Mode**: When enabled, Ondeva will process the items in a separate thread / task. Therefore not blocking the user interface and allow the user to continue navigating.

**Optional Enhancements:**

* **After Completion**: Dialog to show after all iterations complete.
* **Progress Dialog**: Dialog to show to the user during async execution. When creating a custom progress dialog you have to mark the places for the progress information with these CSS classes: `progress-current` for the current progress value and `progress-total` for the total amount of items.

**When to Use:**

* Batch-update rows in a table.
* Call external APIs for multiple records.
* Send personalized emails to a filtered group.

***

### **Call API**

**Purpose:**

Connects to external services by calling any HTTP endpoint and stores the response in session variables.

**Key Options:**

* **Endpoint URL**: The target URL of the API.
* **Method**: `GET`, `POST`, `PUT`, `DELETE`, etc.
* **Auth Profile**: Preconfigured authentication (OAuth, token, etc.).
* **Content Type**: Defines the body format (`application/json`, etc.).
* **Body**: Raw JSON body sent with the request. If the request method allows for a payload.
* **Response Handling**:
  * If **Text**: Store in a session variable.
  * If **File**: Save the response to a specified table field.

**Optional Enhancements:**

* **Headers**: Custom headers (optional).

**When to Use:**

* Integrating with third-party tools (CRMs, payment systems, external DBs).
* Sending dynamic data from Ondeva to another system.
* Consuming REST APIs without needing backend code.

***

### Best Practices

* **Keep steps modular**: Use “Execute Workflow” to isolate logic and improve readability.
* **Use session variables to pass state** between condition checks and API calls.
* **Always handle error cases**, especially for external API calls (e.g., use condition checks on HTTP response codes).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ondeva.com/workflow/steps-reference/logic.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
