Allows for the execution of JavaScript code within the data flow. This provides maximum flexibility for custom data processing, transformations, or integrations.
Inputs
The JavaScript node does not require any mandatory inputs but requires an input payload to trigger the code to run.
Functionality
Used to perform complicated logic operations.
Outputs
JSON format payload
How to Use
Implementation
In the Rayven Workflow Builder:
- Select Functions.
- Drag the JavaScript node to the canvas.
- Provide an input to the JavaScript node by connecting it to another node.
- Double click on the JavaScript node to open the configuration window.
Configuration
Section: General |
||
This section contains basic configuration elements required for any JavaScript node implementation |
||
Field |
Requirement |
Comments |
Node Name |
Mandatory |
Enter a name for this node. This provides a handle to which you and others can refer, so it should be simple but meaningful and explain the node’s purpose. |
JavaScript Templates |
Optional |
Select JavaScript templates to add to your code. For example, if you wish to get the device ID, please select “Add Device ID” from the dropdown list and a code template will be provided. |
JavaScript |
Mandatory |
Enter your JavaScript code here. They “input” key holds the value received by the node while “result” key holds the value that will be sent to the connected nodes after the JavaScript node |
Action on Error |
Mandatory |
Select from dropdown menu
|
Step by Step Section
- The IDE will include pre-written JavaScript input and result code when first opened. This will allow you to access all data as member variables of the object myObject - for example myObject.data. You can change, add, or delete variables as you would for any JavaScript object. You do not have to send myObject to output - you might wish to create an entirely new json - for instance, you might create an object ‘myObject2’ with its own member variables and send that to the result. In this case, only the member variables of myObject2 will be passed to the flow.
- Note that the IDE will provide you with the functionality contained in ECMAscript ES5, with no additional libraries.
- You can add functions to your code, for example:
- function RayvenTest(json_object1, json_object2){
var rayven_obj = {};
(*your code)
return driver_obj;
}
- New objects can be created, for example:
- const date2 = new Date('1995-12-17T03:24:00');
- Rayven specific functionality can be accessed only where the data is in the input. For instance, the device code is a member variable of all payloads and can be accessed with:
- myObject.device_ID = deviceCode;
- In contrast, to access the device payload timezone (for example), you must first place a formula node before the JavaScript node with a formula like:
- deviceTimezone = DEVICE.PAYLOAD.TZ
- Which can then be accessed in the JavaScript IDE by examining the value of myObject.deviceTimezone.
- Note that the JavaScript is server-side. Therefore, you do not have access to browser information. For example, all dates and times are UTC, irrespective of the user’s timezone, and you cannot directly determine the user’s timezone.
- You can also use our JavaScript templates that are ready at hand when you need it.
- There's a few options to choose from.
- For example, if you chose “Add Device ID” to the JavaScript, you will need to move the coding around.
- You will need to move the “myObject.device_ID = deviceCode” to row 13.