Function
Transform
Function is a widget flow node that allows you to execute predefined functions on your data.
Description
The Function node provides a way to perform data transformations, calculations, and other operations using built-in functions. This is useful for manipulating context values, formatting data, or performing calculations before passing data to subsequent nodes.
Configuration
The configuration consists of a list of functions to execute in sequence. Each function has a name and arguments.
Function Name
Function Name – the name of the function to execute. Available functions include:
Name | Description | Arguments |
---|---|---|
Math addition (+ ) | Adds two numbers together | 2 |
Math subtraction (- ) | Subtracts second number from first | 2 |
Math multiplication (* ) | Multiplies two numbers together | 2 |
Math division (/ ) | Divides first number by second | 2 |
Math modulo (% ) | Calculates remainder after division | 2 |
Math power (a^b ) | Raises first number to power of second | 2 |
Math square root (√a ) | Calculates square root of number | 1 |
Math absolute (|a| ) | Gets absolute value of number | 1 |
Math sign | Gets sign of number (-1, 0, or 1) | 1 |
Math floor | Rounds number down to nearest integer | 1 |
Math ceil | Rounds number up to nearest integer | 1 |
Math round | Rounds number to nearest integer | 1 |
String to lower case | Converts string to all lowercase | 1 |
String to upper case | Converts string to all uppercase | 1 |
String trim | Removes whitespace from start and end | 1 |
String length | Gets number of characters in string | 1 |
String replace | Replaces first occurrence of substring | 3 (input, find, replace) |
String replace all occurrences | Replaces all occurrences of substring | 3 (input, find, replace) |
String replace using regular expression | Replaces matches using regex pattern | 3 (input, regex, replace) |
String encode to base64 | Encodes string to base64 format | 1 |
String decode from base64 | Decodes string from base64 format | 1 |
String encode to base64url | Encodes string to base64url format | 1 |
String decode from base64url | Decodes string from base64url format | 1 |
String encode to URL | Encodes string for use in URLs | 1 |
String decode from URL | Decodes URL-encoded string | 1 |
Substring | Extracts portion of string using indices | 3 (input, start, end) |
Arguments
Arguments – the arguments to pass to the function. You can use context values as arguments, and the function will be applied to those values.
WARNING
For string operations, a missing context value is treated as an empty string (''
). For mathematical operations, a missing or non-numeric value is treated as 0
.
INFO
Functions are executed in the order they appear in the configuration. The output of one function cannot be used as input for the next function in the same node.
Limitations
Name | Value |
---|---|
Max functions | 50 |
Max function argument input length | 1024 |
Max compiled argument length | Unlimited |
Inputs | Exactly one |
Outputs | Exactly one |
Context values
Each function in a node generates a context value in the format return_fn_{n}
(where n
is sequential number of a function starting with 1), which contains the result of the function execution.