Node reference
Initialize State
Create missing State and keep saved values across runs
Initialize State creates a saved value only when its key is missing. Later runs keep the existing value on this workflow and runtime.
Try it step by step
- Set Key to lastBalance and choose Empty as its initial type.
- Fetch a balance and use Update State after recording the report row.
- Run again. Initialization keeps the saved balance, ready to compare with the new observation.
What to expect
The output contains key and the current saved value. Existing values are never reset by initialization, including null, false, zero, empty text and empty lists.
Things to check
- Read {{state.lastBalance}} wherever a node needs the latest saved balance. Earlier node outputs are snapshots.
- Use the icon beside the key to choose a literal type, or Text for an expression. An exact expression preserves its value type.
- Update State changes an existing value. Delete State removes it so initialization can create it again.
- Initialization is atomic. It does not lock subsequent work against other branches or overlapping runs.
Keep learning
Parameters
| Setting | Default | What it does |
|---|---|---|
| Key | (empty) | A name private to this workflow. Expressions can choose it dynamically. |
| Initial value | (empty) | Choose a type for a literal value, or use Text for an expression. An exact expression keeps the referenced value and its type. |
| Node name | (empty) | Custom display name. References and connections keep their existing identifiers. |
Node name: Double-brace expressions are not resolved in this field.
Inputs
| Port | Value | Description |
|---|---|---|
in | any | Create the key if it is missing; otherwise keep its saved value. |
Outputs
| Port | Value | Description |
|---|---|---|
out | object | The key and its current saved value. |
out fields
| Field | Type | Description |
|---|---|---|
key | string | Workflow-scoped State key. |
value | unknown | JSON-compatible State value. |