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.

Return Type

Select the type of value returned by the JavaScript function.

  • String

  • Boolean

  • Numeric

  • Currency USD

  • Currency GBP

  • Currency EUR

  • Date

  • Time

  • Kvlist

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

Function

Enter the JavaScript function code.

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.