Workflow Variables
Workflow variables hold shared data during one execution. Define their initial values in the workflow's Variables panel, read them from blocks with <variable.name>, and update them using a Variables block. Runtime assignments do not persist between runs.
Variables allow you to store and share data across your entire workflow, making it easy to maintain state and create complex, interconnected systems.
Overview
The Variables feature serves as a central data store for your workflow, enabling you to:
Store global data: Create variables that persist throughout workflow execution
Share information between blocks: Access the same data from any block in your workflow
Maintain workflow state: Keep track of important values as your workflow runs
Create dynamic workflows: Build more flexible systems that can adapt based on stored values
Creating Variables
Create and manage variables in the workflow's Variables panel or the Workflow Variables widget. Each variable has:
- Name: A unique identifier used to reference the variable
- Type:
plain(plain text),number,boolean,object,array, orlistingIdentity - Initial value: The saved value used to initialize each run; new variables default to empty
plaintext
Accessing Variables
Variables can be accessed from any block in your workflow using the variable dropdown. Simply:
- Type
<in any text field within a block - Browse the dropdown menu to select from available variables
- Select the variable you want to use
When you type < in a text field, a dropdown appears listing all available workflow variables. Select the one you need to insert a reference to it.
You can also drag the connection tag into a field to open the variable dropdown and access available variables.
Variable Types
Variables in TradingGoose can store various types of data:
"Hello, World!"Text variables store strings of characters. They're useful for storing messages, names, and other text data.
42Number variables store numeric values that can be used in calculations or comparisons.
trueBoolean variables store true/false values, perfect for flags and condition checks.
{
"name": "John",
"age": 30,
"city": "New York"
}Object variables store structured data with properties and values.
[1, 2, 3, "four", "five"]Array variables store ordered collections of items.
Using Variables in Blocks
When you access a variable from a block, you can:
- Read its value: Use the variable's current value in your block's logic
- Modify it: Assign a new value using a Variables block
- Use it in expressions: Calculate in Function code or a condition expression; Variables value fields do not evaluate arithmetic
Variable Scope
Variables in TradingGoose have global scope, meaning:
- They are accessible from any block in your workflow
- Changes to variables persist throughout workflow execution
- Every new run loads saved initial values from its live or deployed workflow state; runtime assignments from previous runs are not saved
Parallel instances share these variables, so concurrent writes can overwrite one another. Use per-instance block outputs and aggregate the container's results when isolation matters. For state that must survive separate runs, use persistent storage.
Best Practices
- Use Descriptive Names: Choose variable names that clearly indicate what the variable represents. For example, use
userPreferencesinstead ofup. - Document Your Variables: Explain their purpose in workflow notes; the variable editor has no separate description field.
- Consider Variable Scope: Variables are shared during the run. Connect blocks to enforce ordering where a read depends on an earlier assignment.
- Initialize Variables Early: Set up and initialize your variables at the beginning of your workflow to ensure they're available when needed.
- Handle Missing Variables: Always consider the case where a variable might not yet exist or might have an unexpected value. Add appropriate validation in your blocks.
- Limit Variable Count: Keep the number of variables manageable. Too many variables can make your workflow difficult to understand and maintain.