Skip to main content

Increment

Adds a value to an existing number. This is particularly useful for counters, accumulators, and iterative calculations in RPA workflows.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.

Input

  • Number - The number to increment. Default variable name is num from Message scope. Can reference variables from Message, Flow, or Global scope.

  • Increment Value - The value to add to the number. Default is 1. Can be a constant, variable, or JavaScript expression.

Output

  • Result - The incremented number stored in the specified variable. Default variable name is num in Message scope.
    • Scope - Determines where the result is stored (Message, Flow, Global, or Custom)

Examples

Example 1: Simple Counter

Increment a counter by 1 in each iteration of a loop:

// Input Number (from Flow scope)
${flow.counter}

// Increment Value
1

Output: If counter was 5, the result is 6.

Example 2: Accumulate Sales Total

Add each sale amount to a running total:

// Input Number (from Flow scope)
${flow.totalSales}

// Increment Value (from current message)
${msg.saleAmount}

Output: Running total of all processed sales.

Example 3: Progress Tracking

Increment progress by percentage chunks:

// Input Number
${flow.progressPercent}

// Increment Value
10

Output: Progress increases by 10% each time (e.g., 0, 10, 20, 30...).

Example 4: Dynamic Increment

Increment by a calculated value:

// Input Number
${flow.total}

// Increment Value (JavaScript expression)
${msg.quantity * msg.unitPrice}

Output: Total increases by the product of quantity and unit price.

Tips for Effective Use

  1. Counter Pattern:

    • Initialize counter with Assign node set to 0
    • Use Increment in a loop to track iterations
    • Store counter in Flow scope to maintain value across nodes
  2. Accumulator Pattern:

    • Start with a sum variable set to 0
    • Use Increment to add each value in a collection
    • Useful for totaling amounts, counting occurrences, etc.
  3. Thread Safety:

    • The Increment node uses mutex locks for Flow and Global scopes
    • Safe to use in parallel executions without race conditions
  4. Negative Increments:

    • Use negative values to decrease a number
    • Example: Increment Value of -1 decreases the number by 1
    • However, use Decrement node for clarity
  5. Decimal Precision:

    • The node handles floating-point numbers
    • Be aware of floating-point precision limits for financial calculations

Common Use Cases

  • Loop Counters: Track the number of iterations in a loop
  • Progress Indicators: Update completion percentage or step count
  • Running Totals: Calculate cumulative sums (sales, costs, quantities)
  • Retry Counters: Track the number of retry attempts
  • Item Counters: Count processed items, successful operations, or errors

Common Errors and Solutions

Error: "Number is not defined"

Cause: The input number variable doesn't exist in the specified scope.

Solution: Ensure the number variable is initialized before incrementing:

// First use Assign node to create the variable
${flow.counter} = 0

// Then Increment can reference it
${flow.counter}

Error: "Increment value is not a number"

Cause: The increment value cannot be converted to a number.

Solution: Ensure the increment value is numeric:

// Wrong
${msg.amount} // where amount is "100.50" (string)

// Correct
${parseFloat(msg.amount)}

Floating-Point Precision Issues

Cause: JavaScript floating-point arithmetic can produce unexpected results (e.g., 0.1 + 0.2 = 0.30000000000000004).

Solution: For financial calculations, work with integers (cents instead of dollars):

// Instead of incrementing by 0.01
// Increment by 1 and divide by 100 when displaying

Counter Not Persisting Across Loop Iterations

Cause: Counter is stored in Message scope instead of Flow scope.

Solution: Change the output scope to Flow or Global to persist the value across multiple node executions.