Programme Scripting

Many of the programme steps allow you to run a JavaScript function to further manipulate the programme or run more complicated logic within a programme.

Each function will be a written in JavaScript and have the format:

function(programmeData, moduleData) {
    return {};

In this example,  programmeData pulls in data already stored in the programme. moduleData however contains data from the specified 'Module Data Class'. This argument is optional.

In most steps the object returned is merged into the programme data, overwriting where there is a key collision. See specific step documentation for details on each step.

When testing the JavaScript function, you can use the  logger.warn to write information out to the test log.

More information about available  logger functions is available from the Accessing the Logger page.

When using a programme step that uses javascript, there are a few utility functions available globally to call.

The momentjs and momentjs timezone library are available for use.

Cryptographic hashing is available as part of the `_i.crypto` namespace.
Functions available are sha1, sha256, encodeBase64 and decodeBase64.
Use like `var hash = _i.crypto.sha256("string to hash");`

When dates and datetimes are passed from programme data into the javascript functions, depending on the type of module and the configuration of the model the data can be passed in as a number representing time in milliseconds or an array of [YYYY, MM, DD] where the month is human readable.

A `parseDateValue` function is available as `_i.utils.parseDateValue(datevalue)`. This will take either an array or a number and return a valid date or null if the value passed can't be turned into a date. To ensure you get a default value call `_i.utils.parseDateValue(datevalue) || "default"`.

Still need help? Contact Us Contact Us