Basic Functions
Basic functions are essential for data processing and serve as the foundational components for developing business logic. To utilize the basic functions:
Find the
Functionality
panel on the left-hand side of the screenExpand
Utilities
and thenBasic Functions
Drag the function you want to use into a section on the logic board
Returning the same value
The echo
function returns the given input without modification. It can be utilized for intermediate processing within a workflow or for debugging purposes. Additionally, echo
serves as a method to generate static input values within the application logic.
Merging objects
mergeObjects
can combine two or more objects into one.
You can do so by following these steps:
To add more objects, click the
+
symbol next to the initial input box. This action will create a new input box for each additional object you want to add.Drag the object boxes onto the inputs in the order you want to add them together.
Trigger the function and expand the output to see if it matches your desired format.
Appending to an array
The arrayPush
function appends arrays or individual items to an existing array. To add items or arrays, include them as arguments. Manual static inputs are also supported.
To create a new array:
Drag the array you want to extend onto the first input.
Then drag the items individually into the further inputs, following the order you in which you want to add them.
If necessary, simply add new input boxes by clicking the
+
icon after any existing input box.Trigger the function.
Mapping a range
The mapRange
function transforms a numeric value from an original range to a target range, both of which are defined by the user. This utility allows for scaling of numbers to fit into different numerical contexts or representations.
To achieve this, follow these steps:
To enter a value for mapping, type it directly into the first input field or drag and drop an output value onto it.
Define the ranges in the second input by writing the names of the corresponding variables with a colon, then a space and then the value.
Hit enter for a line break and add the next value.
You may copy the below code and insert it into the input box, then define the ranges by replacing null
with your values.
Adding a delay
The delay
function allows you to postpone the propagation of a value in your application, providing greater control over when specific actions occur.
To configure a delay:
The first input field specifies the ID for the delay timer. This ID is used for incorporating multiple delays and required starting from the first delay. Each delay needs its own unique ID.
Add a second input field to insert or link your value.
Introduce a third input field and specify your desired delay in milliseconds (e.g.,
timeout: 5000
for a five second delay). If this field is omitted, a default of 1000 milliseconds (one second) is applied.Drag your value onto the Trigger to ensure this delay is activated whenever the input value is modified.
If you wish to trigger this delay with every input update, even when the value remains the same, click
change
in the Trigger section and select the appropriate operational mode.
Checking for true parameters
Checking for all true parameters
To execute a logical AND
operation across multiple variables, you can utilize the areAllParamsTrue
function. It accurately returns true
only when every provided input evaluates to true.
The truth value of the result is determined as follows:
Leaving a box blank, inserting
NULL
,0
orfalse
or having fewer boxes than the defined number of parameters will result in the outputfalse
.Any other value in the input boxes will result in
true
Additional boxes above the defined number of parameters will be ignored ONLY if they are empty. Otherwise, the output will be
false
.
How to use the function:
Define the number of needed parameters in the first input box
Add the amount of necessary input boxes
Manually insert or link data
Trigger the function or create a conditional trigger by linking
Checking for one or more true parameters
The isOneOrMoreParamTrue
function operates using a logical OR
operation, in contrast to using a logical AND
operation. This function returns true
if at least one of its given parameters is true.
Filling an input box with content other than leaving it empty, entering NULL
, 0
, or false
is interpreted as true
.
In contrast to areAllParamsTrue, you don't need to define the number of input boxes. Just follow these steps:
Create however many inputs you need
Manually insert or link values
Trigger the function or create a conditional trigger by linking
Converting JSON data to a string
jsonStringify
automatically converts an input to a suitable JSON string. The input should be an object or an array. Subsequent input boxes after the first one are ignored.
Parsing JSON data
The jsonParse
function can interpret JSON data from outputs, transforming them into objects that can be utilized in other functions.
NOTE: When manually specifying JSON in a function's input, it is automatically converted into an object. Therefore, explicitly converting it with this function is unnecessary.
NOTE: When manually specifying JSON in a function's input, it is automatically converted into an object. Therefore, explicitly converting it with this function is unnecessary.
Merging arrays
mergeArrays
is a function designed to combine multiple arrays by nesting their elements one level deeper into a new array structure. It requires at least one array as input. The function compares the lengths of the input arrays and creates a new array with the length matching the shortest input array. Elements from the original arrays are repositioned as sub-elements at their respective indices within this new array. Any elements beyond the length of the shortest input array are omitted in the output.
To merge arrays:
Add inputs as needed
Drag array within outputs onto the inputs or specify them manually
Trigger the function or create a conditional trigger to run this every time an input array changes
Renaming object keys
The renameObjectKeys
function is designed to modify the keys in an object based on a provided mapping. It requires two parameters:
Source Object: The object whose keys need updating, containing original key-value pairs.
Mapping Object: An object defining the new key names, with each property pairing a new key name with its corresponding old key name
newKey: oldKey
.
Remember to write each mapping in a new line by hitting enter.
For source objects with variable key names, you can drag a dynamic key mapping object into the second input to adapt accordingly.
Last updated