DRAGOPS
DRAGOPS
DocumentationGuidesUse variables

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.

  1. Open your pattern in the visual editor.
  2. Select an empty area of the canvas (deselect all nodes) to show the pattern-level Inspector Panel.
  3. In the Variables section, select Add Variable.
  4. 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

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.

  1. Right-click on the canvas and search for "Set Variable".
  2. Add it to the canvas.
  3. Select the node to open the Inspector Panel and choose the variable from the Variable dropdown.
  4. Wire the value you want to store to Set Variable's Value input pin.
  5. 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.

  1. Right-click on the canvas and search for "Get Variable".
  2. Add it to the canvas.
  3. Select the node and choose the variable from the Variable dropdown.
  4. 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

  1. Create a variable named emails with type Array and a default value of [] (empty array).
  2. Build this flow:

How it works

  1. On Webhook receives a payload with a users array.
  2. Get Property extracts the users array.
  3. For Each iterates over each user object.
  4. Inside the loop, Get Property extracts the email field from the current item.
  5. Get Variable retrieves the current emails array.
  6. Array Push adds the email string to the array.
  7. Set Variable stores the updated array back into the emails variable.

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

  1. Create a variable named hasExpensiveItem with type Boolean and a default value of false.
  2. Build this flow:

After the loop

How it works

  1. The hasExpensiveItem variable starts as false.
  2. Inside the For Each loop, each item's price is checked against the threshold.
  3. If any item exceeds the threshold, the variable is set to true.
  4. 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

TypeDefault value exampleNotes
String""Empty string
Integer0Whole numbers only
Float0.0Decimal numbers
Booleanfalsetrue 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 processedCount instead of count, or hasError instead of flag. 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.

What is next?

On this page