Javascript Node

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

  • Continue - Add Error to JSON
  • Continue - Ignore Error
  • Stop - Log Error

Step by Step Section

  1. 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.
  2. Note that the IDE will provide you with the functionality contained in ECMAscript ES5, with no additional libraries.
  3. You can add functions to your code, for example:
  4. function RayvenTest(json_object1, json_object2){

       var rayven_obj = {};

    (*your code)

       return driver_obj;

    }

  5. New objects can be created, for example:
  6. const date2 = new Date('1995-12-17T03:24:00');
  7. 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:
  8. myObject.device_ID = deviceCode;
  9. 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:
  10. deviceTimezone = DEVICE.PAYLOAD.TZ
  11. Which can then be accessed in the JavaScript IDE by examining the value of myObject.deviceTimezone.
  12. 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.

  1. You can also use our JavaScript templates that are ready at hand when you need it.
  2. There's a few options to choose from.

  1. For example, if you chose “Add Device ID” to the JavaScript, you will need to move the coding around.
  2. You will need to move the “myObject.device_ID = deviceCode” to row 13.