Using Integration Functions

This article is intended as reference for OneTrust customers of the specific FreeMarker variables and functions available for use within the Integrations module.

For more information and resources for FreeMarker, see the following:

Custom Functions

Action

Function Example

Generate MD5 Hash

${md5('hello world')}

Generate SHA256 Hash

${sha256('hello world')}

Generate SHA512 Hash

${sha512('hello world')}

Convert Object to Valid JSON

${stringify('hello world')}

Creation and Access of Dynamic Values

Action

Function Example

Store a Scalar in a Dynamic Value

${set('teststring', 'Hello')}

${set('testinteger', 123)}

Store a List in a Dynamic Value

${set('testlist', ['first', 'second'])}

Store an Object in a Dynamic Value

${set('testhash', { 'name': 'mouse', 'price': 50 })}

Retrieve a Scalar from a Dynamic Value

${get('teststring')}

Retrieve a List from Dynamic Value

<#list get('testlist') as n>${n}</#list>

Retrieve an Object from a Dynamic Value

<#object get('testhash')>${myObject['name']}

List Manipulation

The following table is organized in a procedural manner. Each new action introduces a new function manipulation to the list.

Action

Function Example

Create a List

${set('testlist', ['first', 'second', 'third'])}

Add an Element at the End

${push('testlist', 'fourth')}

Add at the Beginning

${unshift('testlist', 'zero')}

Removes a sequence of elements and replaces with another sequence

CODE
splice(listname, offset, len, replacement)

After splice, list has [zero, mid1, mid2, mid3, third, fourth]

${splice('testlist', 1, 2, ['mid1', 'mid2', 'mid3'])}

Remove and return element at the end

After pop, list has [zero, mid1, mid2, mid3, third]

${pop('testlist')}

After pop, list has [zero, mid1, mid2, mid3, third]

Shift removes and returns an element from the beginning

${shift('testlist')}

After first shift, has [mid1, mid2, mid3, third]

${shift('testlist')}

After second shift, has [mid2, mid3, third]

${shift('testlist')}

Splice can also be used to remove elements. Set an empty replacement

${splice('testlist', 0, 3, [])}

Check size, should be zero

${get('testlist')?size}

Object Manipulation Functions

The following table is organized in a procedural manner to demonstrate how each new action manipulates an object in the given function example.

Action

Function Example

Create a hash and manipulate, these functions only work on the top level properties of an object

${set('testhash', {'first':'gold', 'second':{'medal':'silver'}})}

Get the 'first' property

${hget('testhash', 'first')}

Replace the 'first' property

${hput('testhash', 'first', 'platinum')} ${hget('testhash', 'first')}

Get the 'second' property, this returns a hash

${hget('testhash', 'second')['medal']}

Delete the 'second' property

${hdel('testhash', 'second')}

The get operation returns null, provide a default

${(hget('testhash', 'second'))!'empty'}

Add another property

${(hput('testhash', 'third', [1, 2, 4, 5]))}