Use formulas and functions in the set variable value node

In the Set Variable Value node, you can specify not only simple formulas but also various functions as variable values. This enables flexible and powerful data processing.

How to use

1. Create the Set Variable Value node

  • Within the workflow Set Variable Value nodeAdd.

2. Add a variable

  • In the node's settings screen Add variable click the button.

3. Specify the target variable

  • For the added variable's Target variableSpecify.

4. Select formula mode

  • Choose the method for setting the variable value as Formula.

5. Enter the formula

  • Formula to be assigned Enter the desired formula in the field.

As shown in the example above, formulas can include variables. The available operations and functions are as follows.

Basic operations

  1. Arithmetic operators

    • Addition: +

    • Subtraction: -

    • Multiplication: *

    • Division: /

    • Parentheses can be used: ( )

  2. Remainder operation

    • Operator: %

    • Example:

      • 100 % 2 = 0

      • 100 % 8 = 4

  3. Exponentiation operation

    • Operator: **

    • Example:

      • 100 ** 2 = 10,000

Functions

All functions use the function_name(value) format.

  1. Type conversion

    • to_number(value)

      • Converts a string to a number.

      • Example: to_number('4') = 4

    • to_string(value)

      • Converts a number to a string.

      • Example: to_string(7) = '7'

    • to_boolean(value)

      • Converts a value to a boolean (True/False).

      • Example: to_boolean(1) = True

  2. String functions

    • length(value)

      • Returns the length of a string.

      • Example: length('abcde') = 5

  3. Math functions

    • abs(value)

      • Returns the absolute value.

      • Example: abs(-5) = 5

    • Trigonometric functions:

      • sin(value), cos(value), tan(value)

      • Example: tan(90) = 1

    • Rounding-related functions:

      • ceil(value) (ceiling)

      • floor(value) (floor)

      • round(value) (round)

      • Example: floor(2.1) = 2

  4. Random functions

    • random()

      • Returns a random number between 0 and 1.

      • Example: random() = 0.5423

    • random_int(min, max)

      • minand max Returns a random integer between them.

      • Example: random_int(-1, 2) = -1, 0, 1, or 2

  5. Time-related functions

    • unix_timestamp()

      • Returns the current time as a Unix timestamp.

      • Example: unix_timestamp() = 1601672447


Advanced functions

Advanced functions are mainly used to handle JSON data and lists of strings. When using them, you must keep data formats consistent, and if using strings as values, be sure to enclose them in quotes (' ').

1. dict

  • Description: Creates JSON-formatted data using the given key-value pairs. If the same key already exists, its value is overwritten.

  • Format: dict(key1, value1, key2, value2, …)

  • Result: JSON format

  • Example:


2. dict_set

  • Description: Adds new key-value pairs to existing JSON data. If the same key exists, its value is overwritten.

  • Format: dict_set(@JSON_variable, key1, value1, key2, value2, …)

  • Result: JSON format

  • Example:


3. dict_del

  • Description: Removes a specific key from JSON data.

  • Format: dict_del(@JSON_variable, key)

  • Result: JSON format

  • Example:


4. dict_update

  • Description: Merges two JSON objects. If the same key exists, the value from the latter JSON is used.

  • Format: dict_update(@JSON_variable1, @JSON_variable2)

  • Result: JSON format

  • Example:


5. json_loads

  • Description: Converts JSON data written as a string into a JSON-type variable.

  • Format: json_loads('JSON_string')

  • Result: JSON format

  • Example:


6. json_dumps

  • Description: Converts JSON data into string format.

  • Format: json_dumps(@JSON_variable)

  • Result: String format

  • Example:


7. list

  • Description: Creates a list of strings using the given strings.

  • Format: list(string1, string2, …)

  • Result: List of strings

  • Example:

8. list_append

  • Description: Adds new string values to an existing list of strings.

  • Format: list_append(@string_list_variable, string1, string2, …)

  • Result: List of strings

  • Example:


9. list_reverse

  • Description: Reverses the order of a string list variable.

  • Format: list_reverse(@string_list_variable)

  • Result: List of strings

  • Example:


10. get_by_json_path

  • Description: Extracts the value at the specified path from a JSON variable.

  • Format: get_by_json_path(@JSON_variable, JSON_path)

  • Result: String

  • Example:


11. storage_set / storage_get

  • Description: Stores or retrieves a specific variable value under a given key.

    • Use storage_setto store a value.

    • Use storage_getto retrieve a value. You can manage data by sharing key values across the entire project.

  • Format:

    • Save: storage_set('key', @variable)

    • Retrieve: storage_get('key')

  • Result: Same type as the stored variable

  • Example:

12. contains

  • Description: Checks whether a specific string is included in a list of strings.

  • Format: contains(@string_list_variable, string)

  • Result: Boolean (True or False)

  • Example:


13. append

  • Description: Adds a new string to a list of strings.

  • Format: append(@string_list_variable, string)

  • Result: List of strings

  • Example:


14. unique

  • Description: Removes duplicate values from a list of strings.

  • Format: unique(@string_list_variable)

  • Result: List of strings

  • Example:


15. urlencode

  • Description: Converts JSON format to URL-encoded form.

  • Format: urlencode(@JSON_variable)

  • Result: String

  • Example:


16. urldecode

  • Description: Converts a URL-encoded string to JSON format.

  • Format: urldecode(string)

  • Result: String or JSON

  • Example:


17. regex_sub / regex_isub

  • Description: Replaces parts of a string with another value using regular expressions.

    • regex_sub: Case-sensitive.

    • regex_isub: Case-insensitive.

  • Format:

    • regex_sub(regex_pattern, string1, string2)

    • regex_isub(regex_pattern, string1, string2)

  • Result: String

  • Example:


18. date_format

  • Description: Converts a date to the specified format using a format string.

  • Format: date_format(format_string_date, date)

  • Result: String

  • Example:

20. date_add

  • Description: Adds a number of days to the given date.

  • Format: date_add(date, number)

  • Result: Date

  • Example:


21. today

  • Description: Returns today's date.

  • Format: today()

  • Result: Date or string

  • Example:


22. first_day_of_month

  • Description: Returns the first day of the current month.

  • Format: first_day_of_month()

  • Result: Date or string

  • Example:


23. last_day_of_month

  • Description: Returns the last day of the current month.

  • Format: last_day_of_month()

  • Result: Date or string

  • Example:


24. find_all / find_iall

  • Description: Finds all values matching a regex pattern in the given string and returns them as a list.

    • find_all: Case-sensitive.

    • find_iall: Case-insensitive.

  • Format:

    • find_all(regex_pattern, string)

    • find_iall(regex_pattern, string)

  • Result: List of strings

  • Example:


25. substr

  • Description: Returns the specified number of characters from the start of a string.

  • Format: substr(string, number)

  • Result: String

  • Example:

Last updated