RapidIdentity Cloud Product Guide

Studio Value Expressions

In Studio > Applications > Application > Configure > Record Mappings > Record Type Mapping > Details > Field Mappings > Field Mapping > Details,

When VALUE TYPE is set to EXPRESSION, then VALUE should be one of:

  • An ECMAScript expression

  • An ECMAScript function definition

The expression needs to evaluate to (or if a function definition, needs to return) one of the following types:

  • A (possibly empty) array of strings

  • a string

  • null

  • undefined

Any other return type will be coerced to either a string or an array of strings.

The ECMAScript interpreter used is Mozilla Rhino (currently version 1.7.12), which implements ECMAScript 3 as well as some of the more important features of ECMAScript 2105 (aka ECMAScript 5) and beyond, including support for:

  • basic let and const

  • arrow functions

  • JSON parse/stringify

  • Array functional methods

Unlike Connect, Studio does not allow direct access for scripting Java classes, so you are limited to the core javascript functionality except as provided by two objects that are injected as in-scope variables into the evaluation context of the expression.

SRC and DEST Objects

The SRC object allows access to fields of the primary source record, as well as provides methods that allow you to access secondary source records. The DEST object allows similar access to the fields of the target record.

Note

While either the source or target object may not actually exist (e.g., when we are about to create the target object or when the source object has been deleted), SRC and DEST will always be available but may not have any field values available.

Specifically, SRC will not have a source record available for a field mapping that is only ON_DELETE and the same will be true for DEST for a field mapping that is only ON_CREATE. However, in both cases, you will have access to other functions, such as listing records in the relevant namespace.

The SRC and DEST objects provide the following methods:

  • get(fieldName:string)

    • gets the values for the given field from the source/target record

    • will always return an array of 0 or more strings, even if the requested field does not exist

    • fields can also be accessed as properties (e.g., SRC.fieldName or SRC["fieldName"]) when the name of the field is known in advance and does not conflict with any other properties or method names (e.g., toString, get, getRecord, listRecords)

  • getRecord(id:string)

    • gets the source/target record with the given id

  • getRecord(typeName:string, recordKey:string)

    • gets the source/target record of the given type and recordKey

  • getRecords(ids:string[])

    • gets the source/target records with the given ids

  • getRecords(type:string, field:string, value:string)

    • gets source target records of the given type where the given field equals the given value

  • listRecords(typeName:string[, filter:string[, maxResults:number[, orderBy:string[, firstResult:number]]]])

    Note

    This will use the same syntax as all the other filters in Studio.

    • gets source/target records of the given type and optional search criteria

Records returned by getRecord(), getRecords(), and listRecords() support the same interface for accessing fields and other records as do SRC and DEST.

Note

Use of methods to access other records other than SRC and DEST should be used sparingly, since they do not scale particularly well when the record mapping is applied to millions of records.

LOGGER Variable

The LOGGER variable should always be available in record mapping expressions, and provides access to the following methods:

  • LOGGER.trace(message:object)

    • Emit a log at the TRACE level

  • LOGGER.debug(message:object)

    • Emit a log at the DEBUG level

  • LOGGER.info(message:object)

    • Emit a log at the INFO level

  • LOGGER.warn(message:object)

    • Emit a log at the WARN level

  • LOGGER.error(message:object)

    • Emit a log at the ERROR level

These logs are subject tot he logging level configured on the Studio job.

The methods above accept arbitrary objects (not just strings - a list, an exception, etc.)