- Print
- DarkLight
- PDF
The Set Parameters node offers a simple and efficient way to manipulate task variables. With this node, you can create new variables, clean up variable names or perform operations on variables that are too trivial for a Code node (see Picture 1).
Picture 1. Set State node task flow
Node Settings
Parameters
Key-Value
Key - parameter name. It must be a simple string without quotes or special characters. For new variables, use a unique name that hasn't been used before. When updating existing variables, use their original names as the Key.
Value - parameter value. The value you want to assign to the corresponding Key parameter. The value can be a constant, a variable reference, or a function applied to a variable.
Add "key-value" - adds a new parameter field.
Code editor -code editor of the corresponding JSON.
Other
Alert if the number of tasks in the node queue reaches the following number - If this option is selected, a new condition will be created within the node. It will allow you to monitor whether the number of tasks in the node exceeds the specified threshold.
Maximum interval, for which the task stays in the node before being forwarded - the amount of time a task is allowed to be in this node. Can be specified in seconds, minutes, hours, or days. It can also be specified as a unixtime function. This value must be at least 30 seconds.
Examples
Defining a new parameter
The Set Parameters node provides a straightforward way to add new parameters to your task. To create a new parameter, simply declare it in the Parameters section of the node by providing a unique name and a value (see Picture 2).
Picture 2. Defining a new parameter with the Set Parameters node
For instance, you can define a new parameter called "points" and assign it a value of 100 as a number. Similarly, you can add a task parameter called "Name" and set its value to "Alex" as a string.
When the task passes through the Set Parameters node, any new parameters that you have declared will be added to the task. This means that the "points" parameter, which was not previously part of the task, will now be available for use in subsequent nodes.
It's important to note that the value of a new parameter doesn't have to be a constant like it is in this example. You can assign it a value based on a task parameter, or a value stored in a state diagram.
Modifying the value of a parameter
Replacing
The Set Parameters node allows you to easily replace the value of an existing parameter with a new one. Building on the previous example, where we had the task parameter called "points" set to 100, we now create a task with the same parameter key ("points") and assign it a value of 0 (see Picture 3).
Picture 3. Replacing the value of an existing parameter with the Set Parameters node
We can observe that the original value gets replaced with the new value once the task passes through the Set Parameters node.
It's important to note that for the replacement to occur, the parameter key specified in the Set Parameters node must exactly match the key of the existing task parameter. This ensures that the correct parameter value is updated and does not inadvertently create a new parameter with a similar name.
Changing
In addition to simply overwriting a parameter's value, you can also modify it using various functions. For instance, you can use the $.math() function to add or subtract a certain amount from the original value. Consider the following example: if the "points" parameter originally had a value of 100, you can modify it by adding 100 using the $.math() function, resulting in a new value of 200 (see Picture 4).
Picture 4. Modifying the value of an existing parameter using the $.math() function in the Set Parameters node
If the task goes to its corresponding Error node from the Set Parameter node for any reason, no parameters will be modified or added to it. It will proceed directly to the Error node, completely unchanged, with none of the changes specified by the Set Parameter node being applied.
In this node, you can access a single task parameter or a whole task stored in a State Diagram using these constructions.
Error handling & troubleshooting
When an error occurs in the node, the following fields are added to the initial task depending on the error and node type:
Error parameter name | Parameter description |
---|---|
__conveyor_node_type_return_type_error__ | Error type: hardware (system error), software (error in a node logic/settings) |
__conveyor_node_type_return_type_tag__ | Error tag (see the *-marked errors in Error tag column of the table below) |
__conveyor_node_type_return_type_description__ | Error description in human-readable language. Can be static or dynamic |
Problem/Error tag | Cause | Solution |
---|---|---|
The Set Parameters node sends its tasks to the associated Error node. | A function was called using a missing or incorrectly formatted parameter. | Make sure that all parameters used by your functions were first declared and have the appropriate type. For example, in order to use the $.math({{x}}+{{y}}) function in a task, both parameters x and y must exist and have numerical values. |
See above | A parameter accessed from another State diagram using conv/proc is missing from the state diagram, or has a type other than the one specified. | Change the type of parameter you are requesting; add the required parameter to the state diagram. Note: parameters of type String are an exception. If a String parameter requested using conv/proc doesn’t exist in the state diagram, Set Parameter will work without errors, but the new parameter will be empty. |
See above | A parameter has a non-numerical value, even though it was declared as a Number. For example, x = 1abc (Number). | Remove anything that isn’t numeric (i.e. things other than digits 0-9, the decimal point, negative sign, etc) from the “Value” field when the parameter is being declared. |
See above | A parameter was initialized on one line of the Set Parameters node, and then that same parameter was given a new value on another line. | Parameters get assigned a value after they pass through the node. As such, you cannot modify a parameter in the same node it was first initialized in. To fix this issue, initialize a parameter with the desired value right away, or modify it later using another node. |
*"set_param_wrong_convert_param" error | Parameter value failed to convert with the specified parameter type | Please check and correct the data type of the parameter mentioned in the error message |
*the node errors that are listed with the exact error tag (conveyor_node name_return_type_tag).