Set variable
Keeps a value. A local variable lives for this run only. A shared variable is one value for the whole workflow, kept between runs, so it can count things or remember the last state.
Kind
control:variableGroupData
Credits0.1 credits
Ports out1
How it looks
Settings
| Setting | Required | What it does |
|---|---|---|
| Keep it forscope | Yes | This run (Local) or Every run (Shared). Shared variables are declared on the workflow with a type and a default. |
| Variablevar | Yes | Its name. Names starting with __ are WBSKT's own. |
| Doop | Yes | Set it to a value. A shared variable can also Compare and set, and a shared counter Increment and Decrement. |
| Valuevalue | No | A fixed value, or one from the run. |
| Only if it is nowexpected | No | For Compare and set: the value is written only if the variable holds this now. |
Ports
| Port | The run leaves by it when |
|---|---|
default | After the write. |
What it adds to the run
Later nodes can read these, in a condition or as {{name}} in a text field.
| Value | Holds |
|---|---|
(the name) | A local variable, by its name, for later nodes. |
casSucceeded | For Compare and set: whether the write happened. |
Example
Count the doorbell rings today
- Declare a shared counter
rings, default 0. - In the doorbell workflow, Set variable: Every run,
rings, Increment. - A Schedule at midnight sets
ringsback to 0.
Reading a shared variableUse
{{$shared.NAME}} in any text field, or pick it in a condition. Increment and Decrement are safe with many runs at once; Set is last write wins. You can also set one by hand in the console.Problems you might see
| Code | Means |
|---|---|
VARIABLE_NOT_A_COUNTER | Increment or Decrement on a variable that isn't a counter. |
VARIABLE_NAME_RESERVED | The name starts with __. |
VARIABLE_EXPECTED_MISSING | Compare and set without a value to compare. |
Problems found when you publish stop the publish and point at the node. Problems while a run is going fail the node, and its On failure setting decides what happens next. See the error codes for the API's own.
See also
Checks a condition, or several joined with and or or, and leaves by true or false.
Outtruefalsecontrol:logicStarts every few minutes, daily at a time, or on a cron expression. Times are UTC.
Outdefaulttrigger:scheduleRuns the body once per item of a list, one after another, then leaves by done.
Outbodydonecontrol:foreach