Use variables
Store and retrieve values within a pattern using Set Variable and Get Variable.
Wires carry data directly from one node to the next, but not every data path is a straight line. When you need to store a value in one part of a pattern and use it in another — across loop iterations, between branches, or in disconnected sections of the graph — variables provide that bridge.
When to use variables vs wires
Use wires when data flows directly from a producer node to a consumer node. This is the default and keeps the graph readable.
Use variables when:
- A value needs to be read in multiple places that are not directly wired together
- You need to accumulate a result across loop iterations (for example, building an array inside a For Each loop)
- A value is set conditionally in one branch and used later in the main flow
- You want to track state through complex flow control (counters, flags, intermediate results)
Create a variable
Variables are defined in the Inspector Panel on the left side of the editor.
- Open your pattern in the visual editor.
- Select an empty area of the canvas (deselect all nodes) to show the pattern-level Inspector Panel.
- In the Variables section, select Add Variable.
- Configure the variable:
- Name — a unique identifier (for example,
resultCount) - Type — the data type: String, Integer, Float, Boolean, Object, or Array
- Default Value — the initial value at the start of each execution
- Name — a unique identifier (for example,
Each variable starts with its default value every time the pattern runs. Variables do not persist between executions.
Set Variable
The Set Variable node stores a value in a named variable.
- Right-click on the canvas and search for "Set Variable".
- Add it to the canvas.
- Select the node to open the Inspector Panel and choose the variable from the Variable dropdown.
- Wire the value you want to store to Set Variable's Value input pin.
- Wire the execution flow into Set Variable's execution input pin.
Get Variable
The Get Variable node retrieves the current value of a named variable.
- Right-click on the canvas and search for "Get Variable".
- Add it to the canvas.
- Select the node and choose the variable from the Variable dropdown.
- The Value output pin provides the stored value.
Get Variable is a pure node — it has no execution pins. It evaluates automatically when a downstream node needs its value.
Pattern: Accumulate results in a For Each loop
One of the most common variable patterns is building up a result while iterating over an array.
Goal: Process an array of user objects and collect their email addresses into a new array.
Setup
- Create a variable named
emailswith type Array and a default value of[](empty array). - Build this flow:
How it works
- On Webhook receives a payload with a
usersarray. - Get Property extracts the
usersarray. - For Each iterates over each user object.
- Inside the loop, Get Property extracts the
emailfield from the current item. - Get Variable retrieves the current
emailsarray. - Array Push adds the email string to the array.
- Set Variable stores the updated array back into the
emailsvariable.
After the loop completes, emails contains all the extracted email addresses.
After the loop
Wire the Completed execution output of For Each to a Get Variable node and then a Log node to see the accumulated result:
Pattern: Flag-based flow control
Variables work well as boolean flags to track whether a condition was met during execution.
Goal: Process a list of items and log whether any item had a price above a threshold.
Setup
- Create a variable named
hasExpensiveItemwith type Boolean and a default value offalse. - Build this flow:
After the loop
How it works
- The
hasExpensiveItemvariable starts asfalse. - Inside the For Each loop, each item's price is checked against the threshold.
- If any item exceeds the threshold, the variable is set to
true. - After the loop, a Branch node reads the variable and routes execution accordingly.
The flag "sticks" — once set to true, it remains true for the rest of the execution. This pattern avoids the need to break out of the loop or track results through complex wiring.
Variable types and defaults
| Type | Default value example | Notes |
|---|---|---|
| String | "" | Empty string |
| Integer | 0 | Whole numbers only |
| Float | 0.0 | Decimal numbers |
| Boolean | false | true or false |
| Object | {} | Empty object |
| Array | [] | Empty array |
Choose the type that matches how the variable is used. If a downstream node expects an Integer, define the variable as Integer — DRAGOPS enforces type consistency through the pin system.
Tips
- Name variables descriptively. Use
processedCountinstead ofcount, orhasErrorinstead offlag. Clear names make the graph easier to understand. - Set defaults intentionally. The default value matters — it is the starting state of every execution. An unset integer defaults to
0, which may or may not be the right initial value for your logic. - Minimize variable usage. Prefer wires when the data path is direct. Variables add indirection that makes the pattern harder to trace. Use them when wires cannot reach.
- Variables do not persist between executions. Each execution starts fresh with the default values. For persistent storage across executions, use an external service via HTTP requests.