Documentation Index

Fetch the complete documentation index at: https://help.csgi.com/llms.txt

Use this file to discover all available pages before exploring further.

📢 Announcement:  Xponent Journey Hub, Bill Explainer, and Xponent Communication Control April 2026 (26.1) Release Notes are now available – Check out the latest updates published on April 2026.

JavaScript Node

Prev Next

The JavaScript Node executes any valid JavaScript code as a function and can return any valid JavaScript object as a return value. The function can also update any of its arguments by reference, including public variables. The JavaScript Node supports NodeJS version 20.12.2.

Xponent uses the Node JavaScript engine to execute the JavaScript functions. The full Node library is available with a few notable exceptions for security reasons, which includes the http, os, and fs modules. Any valid Node JavaScript can be executed within the function - including other embedded functions. The Script Editor uses JavaScript syntax highlighting to help ensure that the code is correct.

As well as the full Node library, the JavaScript node includes a number of common packages that support common tasks: 

  • Date and time manipulation (“moment”)
  • User-agent parsing and device detection (“ua-parser-js”)
  • ID generation (“uuid”)
  • Toolkit for working with common data structures ("lodash")
  • Hashing and Encrypting ("crypto library")

See the Examples section below for suggestions on some of the things that you can do with each of these packages. 

JavaScript has reserved words which cannot be used as variables, labels, or function names.

  • Click Add Argument to add the function arguments.

For Example:

The following function will return the concatenation of the two arguments:

Remember to save the script after making changes. 

You can update or delete function arguments by right-clicking on the argument itself:

Clicking on the Update Argument Name will bring up this prompt window:

  • The system will not prompt you for confirmation when deleting an argument.
  • Currently, the JavaScript Node does not allow you to reorder arguments. The workaround is to rename the arguments instead.

Any changes made to the input arguments will be reflected in the schema (or public variable) after the function has run.

For Example:

The function below will set the area value in the schema location that it is mapped to. This can be a simple value or an object.

Semicolons are optional in modern JavaScript.

The JavaScript node is often used to set or change many schema values at once. It can also be used as an alternative to a series of Set nodes by setting all of the values in a single node.

For Example:

The function below will create a complex JavaScript object that can be mapped into the schema or a public variable.

All of the Node JavaScript libraries are available except the http, fs, and other libraries for security reasons. This example uses the Node Math library to access the value of PI.

function circleArea(r) {
	// Returns the area of a circle given the radius - r
	const PI = Math.PI;
	return  PI * r * r;
}

Validation Warnings

The JavaScript Node creates no validation warnings. 

Testing 

When testing a JavaScript node, the testing console allows the data specification for each argument to the function. This should be provided as valid input in JavaScript Object Notation (JSON) for each argument. Ignore the Data element on the left of the testing window, as that is not currently used. 

For Example:

Testing the JavaScript node above that returns the two arguments concatenated or added (depending on the type) together when called with two strings: 

Will return as follows: 

However, that function will also work with numeric values: 

Advanced Testing 

If your JavaScript Node is more complicated, you must ensure that each argument is given the correct JavaScript object. A slightly more complex version of our JavaScript node: 

Called with these parameters: 

Will produce this output: 

Return Value 

The return value from the JavaScript node can be used directly in an expression. Here is a JavaScript Node that returns a random value in the interval \[0,1\]:

This graph chooses heads or tails randomly on each execution:

Errors

Since a JavaScript node is a function, it has to be named starting with _, $, or any character (a-z, including accents or diacritics). Otherwise, it will throw the following error message:

(Script) return - KW-00-019-00-0001 SCRIPT: Unexpected error running JavaScript: SyntaxError: Unexpected token