Using utility methods in Calculators

The below are some utils methods that can be used in a Calculator step.

Datatype conversion

You can convert a value to a different datatype:

let newValue = utils.convert(val, toType, format);


You can copy an object:

let newObj = utils.copy(obj);

You can hash an object with an algorithm:

let HashObj = utils.crypto.createHash(algorithm, options);

You can create an HMAC for an object:

let HmacObj = utils.crypto.createHmac(algorithm, key, options);

You can create a cryptographically artificial random data with the byte size:

let RandomData = utils.crypto.randomBytes(size);

You can merge a source object to a destination object:

let MergeObj = utils.merge(a, b, options);


You can generate a schema from a JSON object:

let newSchema = utils.schema.generateSchemaFromJSON(obj);

You can flatten a schema:

let newSchema = utils.schema.flattenSchema(schema, options);

You can validate a schema in a document:

let validateSchema = utils.schema.validate(document, schema, coerce, showAllErrors);

You can merge schemas:

let mergeSchema = utils.schema.mergeSchemas(schemas);

Escape XML Entities

You can escape XML entities by replacing them:

let safeXML= utils.escapeXml(xmlString);

Exclude Empty Arrays:

return Object.entries(input.record.fieldName).length = 0

Convert runDate to an epoch time:

input.parameters.fromDate = utils.dayjs(input.runInfo.lastRun).valueOf()

Byte buffers in Calculators

Using DayJS in Calculators

Miscellaneous Calculator Functions