Inside the body, any actions can be performed using the passed object in the context of the product layer. +\ At the output, the returned result is stored in a variable, and also, if an object is returned, all its keys are compared with the variables available in the script and the values are saved.
Component JS Code
:icons:font :hardbreaks: :imagesdir: ../../../assets/images :toc-title: Contents :toc:
Description
Executes the JS code specified by the argument in the product layer microservice. :description2: Passes as input either an object with the values of the variables or an object with the specified named arguments. +\
Example: "return { a: x + y.name + z[0].caption };" for passed variables or parameters x = "abc", y = {"name": "def"}, z = [{"caption": "ghi"}] will return "abcdefghi" and assign it to the existing script variable 'a', as well as the body of "{ a: "abcdefghi" }" to the variable returning the result, if specified.
If necessary, you can perform an asynchronous request: "return async function() { await GlobalUtils.wait(500); return { a: 1, b: x }; }".
Index |
|
Short name |
|
Script types |
|
Start module |
|
Mode |
Asynchronous |
Icon |
|
Branching type |
Branching |
Limitations
-
If a timeout is triggered, the script stops waiting for a response and passes control to the next component, the executing method does not complete.
Properties
| Specification | Description |
|---|---|
Name: JS Code Code: Visibility condition: no Default: — |
JS function code for execution in node.js in a product layer microservice environment. |
Name: Method for setting parameters Code: Visibility condition: no
Default: |
Toggles the mode for setting parameters for the runtime environment. Possible values:
When passing values, JSON strings representing objects are available in the code as objects, JSON arrays are available as arrays, strings and numbers by default, dates are available as a string, and unfilled values remain null. |
Name: Arguments Code: Visibility condition: yes Default: — |
List of passed parameters and their names. Access to them from the executing code through names as to ordinary variables. If the value is a JSON string with an object or array, then the JS code will directly access the object or array when accessing the corresponding variable. |
Name: Timeout, sec Code: Visibility condition: no Default: 5 |
Argument defining the code execution timeout in the JS node. When the timeout expires, the script passes control to the 'Transition, timeout' branch, and the code continues to execute. |
Name: Result into variable
Code: Default: — |
Variable where the full body of the execution result is saved. If the JS code returns an object or array, then the JSON string representation of it is stored in the variable. |
Name: Error in variable Code: Visibility condition: no Default: — |
Variable where the string with the error code and text is saved. Some expanded errors are saved to the log. |
Name: Transition Code: Visibility condition: no Default: — |
Component to which control is transferred. |
Name: Transition, time Code: Visibility condition: no Default: — |
The component to which control is transferred in case of a timeout. |
Name: Transition, error Code: Visibility condition: no Default: — |
Component to which control is transferred in case of an error. |