Variable Task¶
Overview¶
The Variable Task stores and retrieves data within a workflow execution. Use it for temporary calculations, counters, flags, intermediate results, or passing data between distant tasks.
When to use this task:
- Store calculated values for later use
- Count loop iterations or successes
- Set flags for conditional logic
- Cache data to avoid repeat queries
- Accumulate totals across loop
- Store intermediate processing results
- Pass data across complex workflows
Key Features:
- Store any data type (text, numbers, JSON)
- Persist within workflow execution
- Access anywhere in workflow
- Update incrementally
- Multiple variables per workflow
- No external dependencies
- Fast and reliable
Outputs¶
Reference fields as {{task_<ID>_<field>}}.
| Field | Type | Notes |
|---|---|---|
task_id |
string | This task's own ID. |
value |
string | The stored value. |
updated_task_id |
string | The ID of the Variable task that was written to, when this task updated or appended to another one. |
appended |
string | Append only: the text this task added. Not the whole value — read that from the variable itself. |
length |
number | Append only: how long the variable is now, in characters. Also reported when an append is refused. |
Always emitted¶
| Field | Type | Notes |
|---|---|---|
run |
boolean | Whether the task succeeded. |
run_text |
string | What happened, including the reason on failure. |
Fields marked as action-dependent may be absent
This task does several different things depending on its action setting, and only the fields relevant to that action are emitted. Check a real run in the OUTPUT panel before referencing one downstream.
Quick Start¶
- Add Variable task
- Set variable name
- Set variable value
- Access later:
{{task_41001_value}} - Save
Simple Example:
Configuration¶
Builder fields¶
The Field column is the label as it appears in the task builder; Key is the name the value is stored under and referenced by.
| Field | Key | Type | Default | Notes |
|---|---|---|---|---|
| Action | action |
select | create |
Options: Create Variable · Fetch Variable · Update Variable · Append to Variable |
| Task ID | task_id |
text | – | Only shown when action is fetch, update, append |
| Variable Value | value |
textarea | – | Only shown when action is create, update |
| Text to Append | value |
textarea | – | Only shown when action is append |
| Delimiter | delimiter |
text | – | Only shown when action is append. Left out while the variable is empty |
Set Variable¶
Store calculation result:
Store text:
Store dynamic data:
Store JSON:
Variable Naming¶
Best practices:
- Use descriptive names:
lead_scorenotvar1 - Snake_case preferred:
total_countnottotalCount - Be specific:
email_sent_countnotcount
Accessing Variables¶
After Variable task executes:
Access value:
Use in If condition:
Use in Email:
Use in a later task:
UPDATE contacts SET score = ? WHERE id = ?
Parameters: {{task_41001_value}}, {{task_47001_contact_id}}
Common Patterns¶
Counter¶
Increment in loop:
// Code task in loop
let count = parseInt(input.task_41001_value) || 0;
if (input.task_x_success) {
count++;
}
return { counter: count };
Store new count:
Access after loop:
Flag Storage¶
Set flag based on condition:
// Code task
const isHighValue = parseFloat(input.task_43001_total) > 10000;
return { high_value_flag: isHighValue };
Store flag:
Use in If task:
Cache Data¶
Avoid repeat queries:
1. Match to Client - look the client up once
2. Variable - store the value you need repeatedly
3. Loop - process the items
4. In loop: read {{task_41001_value}} instead of looking it up again
Building a list inside a loop¶
Use Append to Variable, not Update. Append adds your text to the end of the variable in one step, so a loop set to run its items in parallel can build the list without items overwriting each other:
Action: Append to Variable
Task ID: 41001 ← the Create Variable task
Text to Append: {{task_29001_loop_value}}
Delimiter: |
Update does the opposite — it reads the whole value, changes it, and writes it back. Two items doing that at once lose one another's text, so a loop whose items update a variable created outside the loop is made to run one item at a time. Its node says "Sequential", and the loop's panel names the task responsible. Switching that task to Append gives the loop its parallelism back.
Things worth knowing:
- The delimiter is skipped while the variable is empty, so the list never opens with one.
- Entries appear in the order items finish, not in list order. In parallel that is not the order you started them in.
- A variable holds 100,000 characters. An append past that fails with "Variable is full: 100,000 character limit reached" and leaves the value unchanged — it is never cut short, so a summary that looks complete always is.
- The output is the appended text and the resulting length, not the whole value. Read the value from the Create Variable task.
Accumulator¶
Sum values across loop:
// Code task in loop
let total = parseFloat(input.task_41001_value) || 0;
total += parseFloat(input.task_29001_amount) || 0;
return { running_total: total };
Update variable:
Real-World Examples¶
Carry a value past a long branch¶
Webhook In
└─ Variable store the order reference
└─ If Statement
└─ Email quote {{task_41001_value}} in the message
The Variable task holds a value so a task further down the workflow can read it without referencing a task several steps back.
Keep a running count inside a loop¶
Read it back later as {{task_41001_value}}. updated_task_id tells you which Variable task was
written to when one Variable task updates another.
A variable lives for one workflow run
It is not storage between runs. For something that must survive the run, write it to the client record with Edit Client or to a sheet with Google Sheets.
Best Practices¶
Naming Conventions¶
- Descriptive names -
email_sent_countnotcount - Context-specific -
loop_success_totalnottotal - Consistent format - All snake_case or all camelCase
- Avoid conflicts - Don't reuse same name for different data
When to Use Variables¶
Good use cases:
- Calculations used multiple times
- Counters and accumulators
- Flags for conditional logic
- Caching expensive queries
Bad use cases:
- Data available from previous task (just use that task's output)
- Passing data to next immediate task (direct reference better)
- Storing large datasets (use database instead)
Performance¶
- Don't overuse - Only store what you need later
- Keep values small - Large JSON can slow workflow
- Clean data - Store processed, not raw data
- Use direct references - If task output available, use it directly
Data Types¶
Store appropriate format:
Numbers:
Text:
Boolean:
JSON:
Troubleshooting¶
Variable Empty or Undefined¶
Check:
- Variable task executed before access?
- Correct task ID in reference?
- Value set in configuration?
- Previous task output exists?
Debug:
Can't Access in Loop¶
Issue: Variable set outside loop, not updating inside
Solution: Update variable inside loop:
Lost After Loop¶
Issue: Variable value from loop lost
Cause: Variable holds last iteration value only
Solution: Use accumulator pattern (see Example 2).
Number Stored as Text¶
Issue: Math operations fail
Solution: Parse in Code task:
Frequently Asked Questions¶
How long does variable data persist?¶
Duration of single workflow execution. Not saved between runs.
Can I use variables across different workflows?¶
No. Use database or Edit Client task for persistent storage.
How many variables can I create?¶
Unlimited, but practical limit ~10-20 per workflow for clarity.
Can I store arrays?¶
Yes, as JSON:
Value: [1, 2, 3, 4, 5]
Access: {{task_41001_value}}
Parse in Code task: JSON.parse(input.task_41001_value)
Can I update a variable?¶
Yes, add another Variable task with same name:
Overwrites previous value.
What's difference between Variable and Edit Client?¶
- Variable: Temporary, workflow-only, fast
- Edit Client: Permanent, saved to CRM, slower
Can I use variables in If conditions?¶
Yes:
How to access variable in different format?¶
Use Code task to transform:
const value = input.task_41001_value;
return {
uppercase: value.toUpperCase(),
length: value.length,
reversed: value.split('').reverse().join(''),
};
Related Tasks¶
- Code Task - Calculate values to store
- If Task - Conditional logic with variables
- Loop Task - Counters and accumulators
- Edit Client - Permanent storage alternative