Running Custom Code
You can write JavaScript to interact with inputs and utility libraries, which is useful for adding custom logic to your application services. In service designer you can use the Run JavaScript Code node to write your custom code. Altogic automatically injects predefined list of utility libraries and node input values to the code execution context.

Accessing Node Inputs
You can access the values of object
, list
or value
inputs in your custom JavaScript code using their names. Please note that, trigger link points added to this node as input will not be injected, since these linkpoints to do not have any values. In below example, a single users
model object is passed to Run JavaScript Code node execution context as pickedValue
. You can access the value of this input by using the ctx.pickedValue
keyword in your custom code.

info
To access the input link point values in your custom code, you need to prefix the input names with ctx keyword (e.g., ctx.input, ctx.request).
Libraries
The Run JavaScript Node automatically imports the following utility libraries. You can use the keyword (e.g., moment, _, luxon) in your custom code to access the methods, classes and properties of these libraries.
Library | Keyword | Docs | Version |
---|---|---|---|
Altogic | altogic | https://www.altogic.com/client | v2.3.9 |
Axios | axios | https://www.npmjs.com/package/axios | v1.3.2 |
Decimal.js | decimal | https://www.npmjs.com/package/decimal.js | v10.2.0 |
Node Fetch | fetch | https://www.npmjs.com/package/node-fetch | v2.6.9 |
Lodash | _ | https://www.npmjs.com/package/lodash | v4.17.21 |
Luxon | luxon | https://www.npmjs.com/package/luxon | v3.2.1 |
Moment | moment | https://www.npmjs.com/package/moment | v2.29.4 |
info
You can directly use the await
operator at your top level custom JavaScript code.