Variables
Variable steps manage data storage during flow execution. Variables hold intermediate results, enable data transformation, and store values for use across multiple steps.
New Variable
Creates a new variable to store data during flow execution.
| Parameter | Description |
|---|---|
| Name | Unique name for the variable |
| Type | Data type (String, Integer, Entity, DateTime, Money, etc.) |
| Is List | Whether this variable holds a collection of values |
| Initial Value | Optional starting value for the variable |
Example - Simple Variable:
NEW VARIABLE
Name: TotalAmount
Type: Money
Is List: false
Initial Value: 0
Example - Entity Variable:
NEW VARIABLE
Name: ProcessedOrder
Type: Entity (Order)
Is List: false
Example - Collection Variable:
NEW VARIABLE
Name: SelectedProducts
Type: Entity (Product)
Is List: true
Initial Value: []
Update Variable
Changes the value of an existing variable.
| Parameter | Description |
|---|---|
| Variable | The variable to update |
| Set Variable | The new value to assign |
Example - Simple Update:
UPDATE VARIABLE
Variable: TotalAmount
Set Variable: TotalAmount + LineItem.Amount
Example - Update Entity Field:
UPDATE VARIABLE
Variable: ProcessedOrder.Status
Set Variable: "Completed"
Example - Add to Collection:
UPDATE VARIABLE
Variable: SelectedProducts
Set Variable: APPEND(SelectedProducts, CurrentProduct)
Set Output
Sets the output values that will be returned when the flow completes.
| Parameter | Description |
|---|---|
| Output Bindings | Map of output names to values |
Outputs are defined in the flow's structure and Set Output assigns values to them. A flow can have multiple Set Output steps—the last value set for each output is what gets returned.
Example:
SET OUTPUT
Output Bindings:
Success: true
ProcessedCount: TotalProcessed
ResultMessage: "Processed " + TotalProcessed + " records"
Conditional Outputs:
CONDITION: Was Successful?
Condition: ErrorCount == 0
TRUE BRANCH:
SET OUTPUT
Success: true
Message: "All records processed"
FALSE BRANCH:
SET OUTPUT
Success: false
Message: "Completed with " + ErrorCount + " errors"
Variable Scope
Variables are scoped to where they are created:
| Scope | Visibility |
|---|---|
| Flow Level | Available to all steps in the flow |
| Branch Level | Available only within the branch (Condition/Switch) |
| Loop Level | Available only within the loop/iterator |
Example:
NEW VARIABLE: FlowTotal (Flow Level)
ITERATOR: Process Items
Collection: Items
NEW VARIABLE: ItemTotal (Loop Level - recreated each iteration)
Steps:
→ ItemTotal = Item.Quantity * Item.Price
→ FlowTotal = FlowTotal + ItemTotal
Variable Types
| Type | Description | Example Values |
|---|---|---|
| String | Text data | "Hello", "Order-001" |
| Integer | Whole numbers | 1, 42, -100 |
| Decimal | Decimal numbers | 3.14, 99.99 |
| Money | Currency values | $100.00, €50.00 |
| Boolean | True/false | true, false |
| DateTime | Date and time | 2024-01-15 10:30:00 |
| Entity Reference | Reference to a record | Account ID, Contact ID |
| Entity | Complete entity record | Full Account record |
| Option Set | Enumerated value | Status, Priority |
Best Practices
Initialize Variables: Always set an initial value, especially for variables used in calculations. Uninitialized variables can cause unexpected behavior.
Use Meaningful Names: Variable names should describe what they hold: CustomerTotalOrders is better than total or x.
Minimize Scope: Create variables at the most specific scope needed. Don't create flow-level variables if they're only used in one loop.
Clean Up Collections: When building collections in loops, be mindful of memory usage with large datasets.
Set Outputs Early for Errors: If your flow might fail or halt, set a default error output early so callers always receive meaningful results.
Avoid Overwriting Unintentionally: Be careful when updating variables in loops—make sure you're accumulating or replacing as intended.