# Parameters & Variables

Ondeva workflows use two types of runtime values to hold and pass data: **Session Parameters** and **Workflow Variables**. These are critical for making workflows dynamic, data-driven, and responsive to user inputs or external API responses.

### **Set Session Parameter**

**Purpose:**

Creates or updates key-value pairs that persist across the user’s entire session.

**Key Options:**

* **Parameter Name**: Any label (e.g., `user_id`, `submission_status`)
* **Value**: Can be static, calculated (via function editor), or fetched from previous workflow steps

**Scope & Availability:**

* Session-wide: Available in **all workflows**, **queries**, and **UI conditions**
* Reference format: `{parameters_parameterName}`

**Use Cases:**

* Store user or environment state (e.g., `{parameters_isAdmin}`)
* Control conditional UI logic (e.g., show/hide components)
* Pass session state into queries or Save Entry steps

***

### **Remove Session Parameter**

**Purpose:**

Deletes an existing session parameter.

**Key Options:**

* Choose from a list of parameters

**Use Cases:**

* Cleanup state after a critical branch completes
* Remove sensitive data from session memory

***

### **Set Variable**

**Purpose:**

Creates a local variable that exists only for the current workflow run.

**Key Options:**

* **Variable Name**: Identifier (e.g., `user_email`, `apiResponse`)
* **Value**: Set via static input or dynamic expressions (function editor)

**Scope & Availability:**

* Available only in:
  * The **current workflow**
  * Any **sub-workflows** triggered from this one
  * Any **queries** loaded within this workflow
* Reference format: `{var_variableName}`

**Use Cases:**

* Store API responses for use in the same flow
* Handle intermediate values like counters or temporary results
* Pass values into Save Entry, API, or condition checks

***

### **Create Object**

**Purpose:**

Constructs a structured object in JSON and stores it as a variable.

**Key Options:**

* **Definition**: Use the editor to build a JSON object
* **Target Variable**: Define where the object will be stored

**Use Cases:**

* Build a request payload before calling an API
* Create a multi-field object to pass into a save or update step
* Package data to hand off to a sub-workflow

***

### **How to Reference Parameters & Variables**

You can use parameters and variables **almost anywhere** in Ondeva workflows — in inputs, field mappings, conditions, and even API bodies.

#### **Syntax:**

* **Variable**: `{var_variableName}`
* **Parameter**: `{parameters_parameterName}`

#### **Where You Can Use Them:**

* **All Workflow Inputs**: Including `Save Entry`, `Call API`, `Check Condition`, `Send Email`, etc.
* **All Queries**: When loaded via workflow, queries can reference workflow variables and session parameters.
* **Design Conditions**: Visibility, enable/disable logic for UI components (parameters only).
* **Sub-Workflows**: Inherit all variables from the parent workflow.
* **Javascript code:** You can access variables and parameters when executing JavaScript code through the “Code” step of a workflow. All variables and parameters are available through the `individee.meta` object.

  ```jsx
  console.log(individee.meta.paramters['var_variableName'];
  ```

### Quick Comparison

| Feature         | Session Parameters                 | Workflow Variables                      |
| --------------- | ---------------------------------- | --------------------------------------- |
| Scope           | Global (across all workflows & UI) | Local (within current + sub workflows)  |
| Lifetime        | Until manually removed or logout   | Until workflow finishes execution       |
| Syntax          | `{parameters_someName}`            | `{var_someName}`                        |
| Use in UI Logic | ✅ (visibility/enabled conditions)  | ❌                                       |
| Use in Queries  | ✅                                  | ✅ (when triggered by workflow)          |
| Best For        | Shared session state               | Internal calculations & short-term data |

***

### Best Practices

* Use **variables** for scoped values that don’t need to persist (API result, loop index, form temp values).
* Use **session parameters** to drive cross-workflow logic and UI behavior (permissions, active user state).
* Clean up unused parameters to avoid polluting the session state.
