Increment Variable

Increment Variable node is designed to increase the value of a specified variable by a given amount. This node is useful for counters, iterative processes, or any scenario where you need to systematically increase a numeric value in your workflow.

Properties Panel

Field

Description

Required

Node name

true

Variable Name

The name of the variable whose value will be incremented.

true

Value

The amount by which the variable will be incremented.

true

Usage

  1. Specify the name of the variable you want to increment.

  2. Enter the increment value (the amount by which the variable will be increased).

Behaviour

  • The node will retrieve the current value of the specified variable.

  • It will then add the provided increment value to this variable.

  • The result of the addition will be stored back in the same variable, overwriting its previous value.

  • If the variable doesn't exist, it'll raise an error.

Returns

The node updates the value of the specified variable with the result of the increment operation. You can access this updated value using Magical Autocomplete (e.g., $.variables.<variable_name>) in any node below this node.

Example

Let's say you want to increment a counter by 1. You already have a variable counter:

  1. Set Variable name to $.variables.counter

  2. Set Value to 1

If counter initially had a value of 5, it will now be 6.

Best Practices

  • Ensure that the variable you're incrementing contains a numeric value to avoid type conversion errors.

  • Always ensure that the variable is initialized before using this node.

Last updated