Functions

Add JavaScript functions to use in the Expression Builder.

Note:

The JavaScript function cannot access external web services. The JavaScript function can only execute code in isolation.

The JavaScript maximum run time is five seconds. It can use up to 10MB memory. When time or memory exceeds that allocated, the function fails silently. The call flow moves on to the next step without the function result.

Name

Give the JavaScript function a name.

Note:

Do not use any JavaScript Reserved Words.

Do not use the name of any Library selected for use within the function.

Return Type

Select the type of value returned by the JavaScript function.

  • String

  • Boolean (true/false)

  • Numeric

  • Currency USD

  • Currency GBP

  • Currency EUR

  • Date

  • Time

  • Kvlist

Note:

The following date formats are supported with two digits for the year, month and date: yy-mm-dd, dd.mm.yy, mm/dd/yy, and yymmdd. In addition, the following date format is supported with four digits for the year: yyyy-mm-dd.

Description

Provide a brief description of the JavaScript function.

Arguments

Define each of the JavaScript function's arguments.

Parameter

Description

Name

Name of the argument.

See also Reserved Words for JavaScript Function Argument Names.

Type

Data type of the argument value.

See also Data Types for JavaScript Function Arguments.

Description

Description of the argument.

Test Value

Test value to use with the Test button.

Note:

The JavaScript function can take at most four arguments. If you need more, create a JSON object. The JSON object counts for one argument and can contain many name-value pairs.

Library

Select the JavaScript libraries that the function requires.

Functionality

Library

Modularity/Performance

Lodash

Underscore

Date-Time

date-fns See also JavaScript date-fns with Studio.

Moment

Cryptography

crypto-js

Important:

When passing an encryption key into JavaScript functions that use crypto.js, we recommend you pass the encryption key inside a secure variable. See Secure Variables. Do not pass values as plain text.

Data Validation

joi

Test Value

zod

Transform XML to JSON

camaro

Transmit information between parties as a JSON object

JSON Web Token

Function

Enter the JavaScript function code.

The maximum code size is 14,000 characters.

Studio automatically adds the name of the function and its arguments.

Test

Test the JavaScript function using the test values supplied in the Arguments section.

Errors

While the task is running, errors are captured in the system log. See System Log and System Log Events.