# 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).
