Overview
This node, named "Workflow Variables Node," allows users to access and manipulate variables that persist within the scope of a workflow execution in n8n. It supports two main operations: Set and Get. The Set operation updates or adds new key-value pairs to the workflow's local variable scope, while the Get operation retrieves values of specified keys from this scope.
This node is beneficial when you want to store intermediate data during a workflow run and reuse it across different nodes without passing it explicitly through input/output connections. For example, you might accumulate counters, flags, or temporary data that multiple parts of your workflow need to reference or update dynamically.
Properties
| Name | Meaning |
|---|---|
| Operation | Choose between Set (to update/add variables) or Get (to retrieve variables). |
| Content (JSON) | JSON object specifying key-value pairs to set or keys to get. |
| Content | Multi-line string input representing JSON content; required for the node to function. |
Note: Both "Content (JSON)" and "Content" represent the same data but in different input formats (JSON editor vs. multi-line text). The node parses this content as JSON internally.
Output
The node outputs an array with one element per input item. Each output item contains:
- A
jsonfield with adebugobject that includes:getInstanceId: The current workflow instance ID.getExecutionId: The current execution ID.operation: The operation performed (setorget).localVarScopeSize: Number of keys currently stored in the local variable scope.- If operation is
set, asetfield showing the entire updated local variable scope. - If operation is
get, agetfield containing the requested key-value pairs retrieved from the local variable scope.
If an error occurs during processing and the node is configured to continue on failure, the output item will include an error field describing the issue.
The node does not output binary data.
Dependencies
- No external services or APIs are required.
- The node relies on internal workflow execution context identifiers (instance ID and execution ID).
- No special environment variables or credentials are needed.
Troubleshooting
- Common issues:
- Invalid JSON in the "Content" property will cause parsing errors.
- Attempting to get keys that do not exist in the local variable scope will return those keys with undefined or missing values.
- Error messages:
- JSON parsing errors if the content is malformed.
- NodeOperationError with context indicating which item caused the failure.
- Resolutions:
- Ensure the "Content" property contains valid JSON.
- Use the "Set" operation first to initialize variables before attempting to "Get" them.
- Enable "Continue On Fail" if you want the workflow to proceed despite individual item errors.
Links and References
- n8n Documentation - Workflow Variables (hypothetical link for illustration)