Method Reference

avg

avg(number1, number2, number3, …)
or
avg(numeric-list-expr)

Parameter

Description

number1, number2, number3, etc.

The numbers from which the average is computed.

numeric-list-expr

A sequence expression containing the numbers to be averaged.

Computes the average of the given numbers.

Example:

<#assign list=[1,73,22]>
${avg(list)}
${avg(1,73,22)}

produces this output:

32
32

NOTE: If you do not provide the numbers or if the sequence is empty avg produces an error, as the average is undefined. To catch that error, use <#attempt> and <#recover>.

bazaarvoiceauthstring

bazaarvoiceauthstring(key, query-string-expr)

Parameter

Description

key

A key/passphrase value that both the sending and receiving party know.

query-string-expr

The decoded and unencrypted query string. 

Helps create links to the Bazaarvoice service.

To create a proper url, you need the base url and the key/passphrase. These will be provided to you in a document that encrypts the required key and query parameters.

Consult technical services for information about how to obtain these two elements, and for further details on how to utilize the Bazaarvoice service.

clickthrough

clickthrough(linkname)
or
clickthrough(linkname, parameter1, parameter2, parameter3, …)

Parameter

Description

linkname

An expression that identifies the link in the link table

parameter1, parameter2, parameter3, …

Additional values to be used in the tracking of the link, in one of the following formats:

“datasourcealias.columnalias”
For replacement of fields coming from the recipient record.

“replacementname=value”
For replacement of values coming from an expression.

See below for an explanation of these values.

You can track clicks on links by first directing these links to a link tracking URL in Interact. Interact will redirect the request to the final URL. For more information, see Forms and Link Tracking.

In Mobile SMS campaigns, the clickthrough method returns a temporary shortened version of the link. The shortened URL is valid fo a short period of time. In email campaigns, this method returns a long URL.

Example:

Assume you want to track clicks to a link on the website http://www.example.com.  To achieve this, you first need to set up and edit a link table for your campaign as follows:

LINK_NAME= Example
LINK_URL= http://www.example.com

This ensures that Interact is ready to track the link. Now, you need to point the document anchor to the link tracking URL in Interact using the clickthrough method.

The link in the user’s email will look different from the original link. When a user clicks the link, clickthrough notifies Interact. Upon receiving the request, Interact redirects the user’s browser to the original URL to get the content (in the example, the page located at http://www.example.com).

Use the following construct to create the link to Interact:

<a href=”${clickthrough(“Example”)}”>Click Here</a>

The clickthrough method creates a link that:

  • Records the fact that a user clicked on it.

  • Optionally, replaces fields in the link tracking table.

  • Redirects the user to the link in the link table.

Sending additional information from content in the recipient record

Sending additional information from the recipient record to the receiving link is usually done on web sites that can receive parameters. For example, when a user clicks a link, you want to provide offers customized to the user’s preferences. The link might look similar to the following:

http://www.example.com/offers?cid=<the-id-of-the-recipient>

To do this:

1. Create a link in the link tracking table with the following information:

LINK_NAME=Offers
LINK_URL=http://www.example.com/offers?cid=${profile.customerid}

2. Construct the clickthrough method as follows:

<a href=”${clickthrough(“Offers”, “profile.customerid”)}”>Find More Offers</a>

Note the use of quotes around the field name. This instructs clickthrough to use that field name to obtain the actual field name (in our example, this is CUSTOMER_ID_0 and its value). Without quotes, clickthrough would look for the field name in the profile.customerid field, an indirection form of the clickthrough method. In general you can use string expressions to specify the field name.

IMPORTANT: The field name resulting from the aliases used in clickthrough must match the field name in the LINK_URL.

Sending additional information from values in the template

To use a specific value from an expression in the template in the replacement of fields, set up the link table as follows:

LINK_NAME=Offers
LINK_URL=http://www.example.com/offers?cid=${RECOMMENDATION}

In this example, the replacement field is a user defined name that you must match in the clickthrough method, not a field in the database . 

The following example illustrates how to recommend offers to the user based on whether the user has a recommendation in his record: if the user has a recommendation, use that recommendation; otherwise use the customer id. 

The field with the recommendation is mapped as pet.recommendationid from a field RECOMMENDATION_ID in a profile extension table.

To do this, set up the clickthrough method as follows:

<#if pet.recommendationid != 0>
  <#assign value=pet.recommendationid>
<#else>
  <#assign value=profile.customerid>
</#if>
<a href=”${clickthrough(‘Offers’, ‘RECOMMENDATION=’ + value)}”>Find More Offers</a>

The expression:

‘RECOMMENDATION=’ + value

means that the replacement name is “RECOMMENDATION” (matching the field replacement in the LINK_URL). = indicates that the field has a value, and the value follows the =. The result of the expression looks similar to:

RECOMMENDATION=43853.

Now, the link will have the fields replaced. In the example, the resulting URL will be:

http://www.example.com/offers?cid=43853.

Tracking links to internal Interact forms

This section describes how to redirect to a form served by Interact. In the example, the form is called userpreferences.

For this example, the link table is set up as:

LINK_NAME= Preferences
LINK_URL=${form(‘userpreferences’, {'usedb':true})}

The LINK_URL contains a form specification.

The template includes the following code:

<a href=”${clickthrough('Preferences')}”>User Preferences</a>

This clickthrough method creates a link to the click processor as in other cases.  When the click is received, the form specification is executed and the user is redirected to the specified form, userpreferences.

Form parameters and implicit tracking of links

Assume the following link table setup:

LINK_NAME= Preferences
LINK_URL=${form('userpreferences', {}, “OPTION”)}

This link loads the form userpreferences and sends the value of the OPTION parameter to the form.  To do this, the clickthrough method must send the option to the form method as follows:

<a href=”${clickthrough(‘Preferences’, ‘OPTION=o’)}”>User Preferences</a>

The clickthrough method must send all required parameters in the form method, otherwise an error will occur. For more information about sending parameters, see “Explicit external link tracking”.

When the form method requires many parameters, keeping the clickthrough invocations in sync with the form method can become quite complex. You can simplify this by marking your personalization as requiring tracking, and then copying the LINK_URL and pasting it in the anchor element as follows:

<a href=”${form('userpreferences', {}, 'profile.useroption')}”>User Preferences</a>

During personalization, the execution engine will recognize anchor tags and will replace this code:

${form('userpreferences', {}, 'profile.useroption')}

with this code:

${clickthrough('Preferences', 'profile.useroption')}

This mechanism of copy/pasting is used to simplify the maintenance of parameter matching. The form method is executed only during the click tracking process, it will not be executed during personalization.

converttimezone

converttimezone(date-expr, from-timezone, to-timezone)

Parameter

Description

date-expr

The base date that used for time zone conversion.

from-timezone

The string identifying the assumed timezone for the date expression.

to-timezone

The string identifying the target timezone for the conversion.

Converts a date to a target timezone.  Dates do not assume a time zone. Conversions from a time zone to a destination time zone need to specify both the source and the destination time zones.

Due to technical limitations, RPL cannot always determine the date type. You can use ?date or ?datetime to properly specify the type of date that is used.

When using ?datetime, or when the type is unknown, the timezone conversion will include hours. When using a date-only expression, the origination time will not have any time, but the result of the converttimezone invocation will include date and time. This resulting date-time will be adjusted according to the requested destination timezone.  When using a time-only field, the conversion will cause an error. The following examples show the different variations.

Example:

<#assign date="2012-12-27 13:25:03"?datetime("yyyy-MM-dd HH:mm:ss")>
${converttimezone(date, "America/Los_Angeles", "Asia/Kolkata")?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2012-12-28 02:55:03

Example using a date-only expression:

<#assign date="2012-12-27 13:25:03"?date("yyyy-MM-dd HH:mm:ss")>
${converttimezone(date, "America/Los_Angeles", "Asia/Kolkata")?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2012-12-17 13:30:00

Note that parsing a date-only string ignores the time. The equivalent result date is then 2012-12-27 00:00:00.  After that, the time is moved 12:30 hours forward.

The following example produces an error:

<#assign date="2012-12-27 13:25:03"?time("yyyy-MM-dd HH:mm:ss")>
${converttimezone(date, "America/Los_Angeles", "Asia/Kolkata")?string("yyyy-MM-dd HH:mm:ss")}

dayadd

dayadd(date-expr, days-expr)

 

Parameter

Description

date-expr

The base date from which the offset will be calculated.

days-expr

The number of days to move forward or backwards.  For backward offsets, use a negative number.

Adds or subtracts the number of days specified by days-expr to a base date specified by date-expr. To subtract days, specify a negative number in days-expr.

For example, adding 1.5 days is equivalent to adding one day and twelve hours.

NOTE: Due technical limitations, RPL cannot always determine the type of date it receives (date only, time only, or both). For this reason, you should use the string built-ins ?datetime, ?date, and ?time to specify the date type.

Example: Advance one day forward and back:

<#assign date="2012-12-27 13:25:03"?datetime("yyyy-MM-dd HH:mm:ss")>
${dayadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}
${dayadd(date, -1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2012-12-28 13:25:03
2012-12-26 13:25:03

Example: Advance one day from a date without time:

<#assign date="2012-12-27 13:25:03"?date("yyyy-MM-dd HH:mm:ss")>
${dayadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2012-12-28 00:00:00

Example: Advance a time forward:

<#assign date="2012-12-27 13:25:03"?time("yyyy-MM-dd HH:mm:ss")>
${dayadd(date, 0.5)?string("HH:mm:ss")}

produces this output:

01:25:03

decrypt

decrypt(code)
or
decrypt(code, key)

Parameter

Description

code

The code previously produced by a call to encrypt.

key

The string that indicates the key that was used during encryption.  This parameter is optional, but should match the key entered during encryption.

Decrypts text that was encrypted with the encrypt method.

Example:

${decrypt(encrypt("some text", "private-key"), "private-key")}

produces this output:

some text

emaildomain

emaildomain(email-expr)

Parameter

Description

email-expr

The email address.

A convenience method that extracts the string representing the domain from the email address. 

Example:

${emaildomain(“jamesbond@m5.com”)

produces this output:

m5.com

encrypt

encrypt(text)
or
encrypt(text, key)

Parameter

Description

text

The expression or string constant for the text to encrypt.

key

The string that indicates the key used for encrypting.  It is optional.  The key same should be given for the equivalent decrypt method.

Encrypts the text that can only be decrypted by the equivalent decrypt method in a form.

Example:

${encrypt("some text")}

produces a string of the form:

E9uV7kzJm13p9SsE_SvvG8s

For security reasons, the string shown in the output above represents possible output for a text string, it is not the real encrypting of the given text string.

exists

exists(path-string)

Parameter

Description

path-string

The string path for the content whose existence to check.

This is the full path to a Content Library file (such as html, text, or an image).

This method checks whether the content at the specified path exists in the Content Library.

The method returns Boolean true if the file at the path-string exists.

The path parameter must be an absolute path, for example:

cms://contentlibrary/foo.htm

If the path starts with the http:// or https:// prefix, the method assumes that the content exists and returns true. Any other value will result in error.

NOTE: You must always use the forward slash (/) to separate path components, do not use the backslash (\).

Example:

<#if exists("cms://contentlibrary/campaigns/promotion-2013-06-27/promotion.htm")>
    The promotion file exists
<#else>
    The promotion file does not exist
<#/if>

The above example outputs the appropriate string whether or not the file exists at the specified path.

Example:

<#if exists("http://www.example.com/couponoftheday/assign"))>
    The coupon link exists
<#else>
    The coupon link does not exist
<#/if>
 

The above example outputs the string “The coupon link exists”.

facebookjoinus

facebookjoinus(link-name, link-url)

Parameter

Description

link-name

The name of the link to be used for Facebook link tracking.

This is the name in the Link table.

The link name must be an expression without commas.

A link name and target URL (LINK_URL) are required.

link-url

The url of the link to be used as a Facebook destination, usually the URL of a page.

This is the URL in the Link table.

A link name and target URL (LINK_URL) are required.

Creates a URL that points to a traceable link to a Facebook page.

Example:

<a href="${facebookjoinus( 'FollowUsFacebook', 'https://www.facebook.com/cocacola')}"><img src="/interact/ui/styles/images/findusonfacebook.PNG"></a>

produces this output, with a link that tracks and opens the Coca Cola page in Facebook:

Standard Images

The standard Facebook image is available in Interact via the image SRC path shown in the following table.  When you use this path, Interact automatically updates the SRC path to the proper Akamai URL for the given Interact account. 

Note that you must type these paths exactly as they appear in the table below (uppercase file extension).

Image Path

Image

/interact/ui/styles/images/findusinfacebook.png

Example:

<img src="/interact/ui/styles/images/findusonfacebook.PNG">

facebooklike

facebooklike(button-type, link-name, button-verb, button-style, description, thumbnail)

Parameter

Description

button-type

The type of like button:

0 = Like an email

1 = Like an offer

link-name

The name of the link for tracking. If buttonType = 0, this parameter preference is ignored.

This is the name of the link as configured in the Link table.

The link name must be a string expression without commas.

A link-name and target URL (LINK_URL) for the offer, in the link table, is required when liking an offer.

button-verb

The verb shown on the Like button:

0 = Like

1 = Recommend

The verb also appears in the individual's Facebook news feed, for example:

Richard likes GiftCo's Sale.

John recommends GiftCo's Sale.

button-style

The format of the Like button on the Like Landing Page:

0 = Standard
On one line, the Like button followed by a text string, "X likes."

1 = Button Count
A horizontal presentation of the button and number of Likes for the item.

2 = Box Count
Stacked presentation of the button and number of Likes for the item.

description

The string shown on the Like Landing Page.  This should be a tag line string of "what" is liked.

If buttonType = 0, this parameter is ignored

Dollar sign symbols must be escaped.

thumbnail

The image used for the Like Landing Page. Recommended size is 200x200 pixels.

Standard Facebook Images

The standard Facebook Like button and Facebook Recommend button images are available in Interact via the image SRC paths shown in the following table. When you use these paths, Interact automatically updates the SRC path to the proper Akamai URL for your Interact account.

Note that you must type these paths exactly as they appear in the table below (all lowercase).

Image Path

Image

/interact/ui/styles/images/likeonfacebook.png

Example:

<img src="/interact/ui/styles/images/likeonfacebook.png">

/interact/ui/styles/images/recommendonfacebook.png

Example:

<img src="/interact/ui/styles/images/recommendonfacebook.png">

facebookshare

facebookshare(title,  summary, image-url)

Parameter

Description

title

A string expression or constant that defines the title that will appear in the Facebook share dialog.

summary

A string expression or constant that defines the description for the link that is being shared in the Facebook dialog,

image-url

The URL to an image that will appear in the Facebook dialog.  If you use an image from the Content library, this image will be published and a link to the externally published image will be used in its place. The recommended image is the logo of your organization.

Creates a button that will give the user the ability to share a story on their Facebook page about the message or part of a message they received. For example, you can share stories about your organization, or stories about the promotion, or a coupon in the current message.

In addition to sharing the story, you can track two additional actions: when someone clicks on the share icon in the message, and when someone clicks the shared link on Facebook. To do this, you need to create two tracking entries in the link table. The link table entries do not need to be added manually. Upon launch, the system automatically adds and maintains the entries in the link table. The Link URLs are computed for both of the tracking actions and might not be URLs that you can easily recognize.

Example:

<a href=”${facebookshare( ‘10% Offer Today’, ‘Today only. Take advantage of this super-saving opportunity on selected items.’ ,'/contentlibrary/media/logo.png')}”>Share in Facebook</a>

produces this output:

Standard image

The standard image for sharing is available in Interact via the image SRC path shown in the following table. When you use this path, Interact automatically updates the SRC path to the proper Akamai URL for your Interact account.

Note that you must type these paths exactly as they appear in the table below (uppercase file extension).

Image Path

Image

/interact/ui/styles/images/sharetofacebook.png

Example:

<img src="/interact/ui/styles/images/sharetofacebook.PNG">

firstname

firstname(string-expr)

Parameter

Description

string-expr

The expression that contains the individual’s full name. Valid formats are:

First Last

Last, First

First M. Last

Last, First M.

This convenience function obtains the first name on a small set of formats. If additional formats are required, we recommend creating a new function in a library. For more information , see function, return and import functions.

form

form(form-name)
or
form(form-name, options-hash)
or
form(form-name, parameter1, parameter2, parameter3, …)
or
form(form-name, options-hash, parameter1, parameter2, parameter3, …)
 

Parameter

Description

form-name

An expression that provides the name to be used as a form. The form must exist either as a campaign or a form, since campaigns can be used as forms as it is the case in the “view in browser” use cases.

When the form method is used in a link URL in a link table, the form name must be a string constant.

options-hash

An optional hash with the following options:

'usedb':boolean-expression
Specifies whether the form function is requesting that the values are retrieved from the database. The default is false. Setting this value to true will read the record from the database, slowing performance.

Example: {‘usedb’:true}

When usedb is set to true, the use of parameters will cause an error since all data comes from the database.

'format':string-expression
An expression or a constant value that returns one of the following values:

’H‘
For a link to the HTML version of the desired form, or

‘T’
For a link to the text-only version of the form. The default is to use HTML document if one exists for the form, text otherwise.

When specifying the desired format, the forms processor checks whether the requested format is available for that form.  If the format is not available, the forms processor return text in the available format.

Example: {‘format’:’H’}

Specific usage examples are provided in examples below.

The hash is required only when you need options other than the default one, or when you are passing parameters. You can also use an empty hash (or {}).

parameter1, parameter2, parameter3, …

The parameters to append to the form for further value resolution.

When usedb is false (the default), these are the values that will be used in the target form.

When usedb is true, using any parameters will cause an error.

The values can be in one of the following forms:

datasourcealias.columnalias
Reads the given field from the current record and sends its value to the target form. The form will receive the field name of the record.

fieldname=value
Sends the given value to the receiving form as specified. The form will receive the field name of the record.

Provides a way to create links to other forms in the system. Forms are defined with a name, and in general both forms and campaigns can be used in this way. For more information, see Forms and Link Tracking.

The form method invocation is usually linked to an HTML anchor tag (“<a href=”” … >”.)  It is flexible and allows for different ways to pass and retrieve information in the linked form as explained in the following scenarios.

In Mobile SMS campaigns, the form method returns a temporary shortened version of the link. The shortened URL is valid fo a short period of time. In email campaigns, this method returns a long URL.

Loading a form with data from the database

The following example shows how to pass overriding values as parameters. The example creates a link to a form called usersettings, requesting that the result be a form in default format.  It will read the current user record:

<a href=”${form(’usersettings’, {‘usedb’:true},)}”>Unsubscribe</a>

Loading a form with the specified parameters

The following example links to a landing page:

<a href=”${form(‘offer’, {}, ‘EMAIL_ADDRESS_=’ + profile.email), ‘MAX_AGE=55’}”>Offers</a>

Assuming that profile.email is provided as an alias to EMAIL_ADRESS_ , this form link provides an email parameter in the receiving form with the email address of the current recipient.

It is worth noting that the value is obtained from the alias, while the email address is fully specified. These values are further concatenated for a string of the form:

EMAIL_ADDRESS_=john@example.com

The previous example can be simplified as follows:

<a href=”${form(‘offer’, {}, ‘profile.email’, ‘MAX_AGE=55’}>Offers</a>

View form in a predefined format in a browser

The following example displays the current campaign in text format:

<a href=”${form(campaign.name, {‘format’:’T’})}”>View as text</a>

The example requests that the text version of the form be rendered. To request the HTML version, specify H for the format parameter. If you do not specify the format, the form will be rendered in the same format as the template being personalized.

IMPORTANT: When you specify an unavailable format, the available one is returned.

houradd

houradd(date-expr, hours-expr)

Parameter

Description

date-expr

The base date from which the offset will be calculated.

hours-expr

The number of hours to add or subtract. For backward offsets, use a negative number.

Adds or subtracts the number of hours specified by hours-expr to a base date specified by date-expr. To subtract hours, specify a negative number in hours-expr.

For example, adding 1.5 hours is equivalent to adding one hour and thirty minutes.

NOTE:  Due technical limitations, RPL cannot always determine the type of date it receives (date only, time only, or both). For this reason, you should use the string built-ins ?datetime,?date, and ?time to specify the date type.

Example 1: Advance one hour forward and back:

<#assign date="2012-12-27 13:25:03"?datetime("yyyy-MM-dd HH:mm:ss")>
${houradd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}
${houradd(date, -1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2012-12-27 14:25:03
2012-12-27 12:25:03

Example 2: Advance one hour on a date without time:

<#assign date="2012-12-27 13:25:03"?date("yyyy-MM-dd HH:mm:ss")>
${houradd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2012-12-27 00:00:00

Example 3: Advance a time forward:

<#assign date="2012-12-27 13:25:03"?time("yyyy-MM-dd HH:mm:ss")>
${houradd(date, 0.5)?string("HH:mm:ss")}

produces this output:

13:55:03

load

load(url-string)
or
load(url-string, encoding)

Parameter

Description

url-string

The string path for the content being provided. Must be a full path to either a Content Library text file (such as html, text only, or xml) or a path to an external http or https resource.

encoding

The encoding that was used to save the file. This value must match the encoding of the file. Using an incorrect value can result on either an error (for invalid encodings) or incorrect output values when using international characters.

Loads the string of a text file, which can be used to assign to a variable or for other similar purposes. Refer to the XML Processing Guide for examples on how to use this method to load XML content into a variable.

NOTE: To work with remote sites, you must have an account enabled for http, https download.

IMPORTANT: This method does not process the content of the file being read as it makes no assumption of the type of contents being read. For example, it will not try to publish images, or encode clicks if the file being loaded was in html format.  Loading html content with additional <head>, <title>, and/or <body> tags might cause undesirable results if the content of the file is outputted verbatim to the resulting stream. This behavior allows you to load any text into the system.

NOTE: <#load> will cache the contents of what is loaded so the message can reference the contents in the cache without having to reload them with each version. This will make the personalization process more efficient and send the email out more quickly.

Example: Output the contents of the html version of the promotion:

<#assign promotion=load("cms://contentlibrary/campaigns/promotion-2013-06-27/promotion.htm")>
${promotion}

Example: Output the coupon code, assuming that the loaded xml contains a sub-element called <number>:

<#assign coupon=parsexml(load("http://www.example.com/couponoftheday/assign"))>
${coupon.number}

IMPORTANT: A request to a URL, as in the second example above, might fail because of communications errors. For instance, RPL might fail to locate the remote site through no fault of its own, the remote site might throw an error under load, or the URL might return the proper content, but RPL fails to receive it because of a communication failure over the wire. Such errors are common, therefore when using load with remote URLs, it is imperative to use <#attempt> and <#recover> to account for them. With this mechanism, the RPL script might be able to assign a default content, skip, or take other action. Failure to use <#attempt>, <#recover> night cause the launch to fail; that is, one communication error that is not recovered will stop a launch of all records.

localtoutc

localtoutc(datetime)
or
localtoutc(date)

Parameter

Description

datetime

A value that contains both date and time.

The date and time are considered local as per the time_zone setting on the template. For more information, see the setting directive.

date

A value that identifies the local date.

The date is interpreted as midnight on the given date.

Converts the datetime or date parameter from local time to UTC datetime, based on the local time configured in the template.

Passing time-only variables will cause an error.

TIP: See utlocal for the inverse operation.

Example with date:

<#setting time_zone="America/Los_Angeles">
<#assign local="2016-09-24"?date("yyyy-MM-dd")>
<#assign utc=localtoutc(local)>
${local?string("yyyy-MM—dd HH:mm:ss")}/${utc?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2016-09-24 00:00:00/2016-09-24 07:00:00

Example with date-time:

<#setting time_zone="America/Los_Angeles">
<#assign local="2016-9-24 13:00:00"?datetime("yyyy-MM-dd HH:mm:ss")>
<#assign utc=localtoutc(local)>
${local?string("yyyy-MM-dd HH:mm:ss")}/${utc?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2016-09-24 13:00:00/2016-09-24 20:00:00

max

max(number1, number2, number3, …)
or
max(numeric-list-expr)

Parameter

Description

number1, number2, number3, etc.

The numbers from which the maximum is computed.

numeric-list-expr

A sequence expression containing the numbers to be compared.

Determines which number is the greatest of the given numbers.

Example:

<#assign list=[1,73,22]>
${max(list)}
${max(1,73,22)}

produces this output:

73
73

NOTE: If you do not provide any numbers, or if the sequence is empty, this method returns an error, as the maximum number is undefined. To catch this error, use <#attempt> and <#recover>.

messagedigest

messagedigest(string-expr)
or 
messagedigest(string-expr, algorithm)

Parameter

Description

string-expr

The string to which the algorithm will be applied.

algorithm

Either “MD5”, “SHA”, or “SHA-256”, “SHA-384”, “SHA-512”.  The default is “SHA”.

Generates a one-way digest by using two standard hashing algorithms. The hashing algorithm converts a string to a unique signature that identifies the message.

You can use this method to deliver encrypted information anywhere in a campaign or form. For example, you might use it to pass encrypted promotion codes in the query string of the link URL so that the destination web site can compare the code to a list of authorized codes.

min

min(number1, number2, number3, …)
or
min(numeric-list-expr)

Parameter

Description

number1, number2, number3, etc.

The numbers from which the minimum is computed.

numeric-list

A sequence expression with the numbers to be compared

Determines which of the given numbers is the smallest.

Example:

<#assign list=[1,73,22]>
${min(list)}
${min(1,73,22)}

produces this output:

1
1

NOTE: If you do not provide any numbers, or if the sequence is empty, this method returns an error, as the minimum number is undefined. To catch this error, use <#attempt> and <#recover>.

minuteadd

minuteadd(date-expr, minutes-expr)

Parameter

Description

date-expr

The base date from which the offset will be calculated.

minutes-expr

The number of minutes to add or subtract.  For backward offsets, use a negative number.

Adds or subtracts the number of minutes specified by minutes-expr to a base date specified by date-expr. To subtract minutes, specify a negative number in minutes-expr.

For example, adding 1.5 minutes is equivalent to adding one minute and thirty seconds.

NOTE: Due technical limitations, RPL cannot always determine the type of date it receives (date only, time only, or both). For this reason, you should use the string built-ins ?datetime, ?date, and ?time to specify the date type.

Example 1: Advance one minute forward and back:

<#assign date="2012-12-27 13:25:03"?datetime("yyyy-MM-dd HH:mm:ss")>
${minuteadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}
${minuteadd(date, -1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2012-12-27 13:26:03
2012-12-27 13:24:03


Example 2: Advance one second on a date without time:

<#assign date="2012-12-27 13:25:03"?date("yyyy-MM-dd HH:mm:ss")>
${minuteadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output (losing the seconds):

2012-12-27 00:00:00

Example 3:  Advance a time forward:

<#assign date="2012-12-27 13:25:03"?time("yyyy-MM-dd HH:mm:ss")>
${minuteadd(date, 1)?string("HH:mm:ss")}

produces this output:

13:26:03

monthadd

monthadd(date-expr, months-expr)

Parameter

Description

date-expr

The base date from which the offset will be calculated.

months-expr

The number of months to add or subtract.  For backward offsets, use a negative number.

Adds or subtracts the number of months specified by months-expr to a base date specified by date-expr. To subtract months, specify a negative number in months-expr.

You cannot use fractional numbers. Fractional numbers are rounded down. For example, 1.5 becomes one, and -1.5 becomes -1. This means that specifying 1.5 months adds one month.

NOTE: Due technical limitations, RPL cannot always determine the type of date it receives (date only, time only, or both). For this reason, you should use the string built-ins ?datetime, ?date, and ?time to specify the date type.

Example 1: Advance one month forward and back

<#assign date="2012-12-27 13:25:03"?datetime("yyyy-MM-dd HH:mm:ss")>
${monthadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}
${monthadd(date, -1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2013-01-27 13:25:03
2012-11-27 13:25:03

Example 2: Advance one month on a date without time:

<#assign date="2012-12-27 13:25:03"?date("yyyy-MM-dd HH:mm:ss")>
${monthadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output (losing the time portion):

2013-12-27 00:00:00

nonce

nonce()
or
nonce(size-number)

Parameter

Description

size-number

A value that determines the string size of the resulting nonce.

Must be between 1 and 128. The default size if the parameter is omitted is 20. Numbers beyond the allowable range  result in an error.

A random string of alphanumeric characters. Nonces are usually used in communication protocols such as Oauth 1, to uniquely identify a request.

Requests with nonces are retryable, if the receiving service is keeping track of the nonces, and thus can reject duplicates.

Example 1:

${nonce()}

produces output of of alphanumeric values. As described above, the output changes with every invocation:

0aPojhKmkk2VlmNTUjfz

Example 2:

${nonce(10)}

produces output of of alphanumeric values. As described above, the output changes with every invocation:

fJk4Ok7Yyz

nonemptyfields

nonemptyfields(field1, field2, field3, etc.)
or
nonemptyfields(sequence-expr)

Parameter

Description

field1, field2, field3, etc.

The names of the fields to be examined.

sequence-expr

A sequence or an expression that produces a sequence.  This is useful, for instance, for use with the randomsubset method.

In some cases, the personalization record is set up so that some fields might be empty. This is done so that only the fields that actually contain values are used.

This method allows you to create dynamic content by specifying a complete set of potential values, but retrieving only the values appropriate for the current record.

To extract the field names, use the hash built-in ?keys. To extract only the values, use the hash built-in ?values.

This method returns a hash with the proper field names and values associated with it.

In the following example, the personalization record for Mary has values in the fields Boots and Backpacks, with the values 2 pair and 1, respectively:

<#assign populated=nonemptyfields(“Hats”, “Shirts”, “Shorts”, “Boots”, “Backpacks”, “Tents”)>
<#list populated?keys as fieldName>
    - ${fieldName} - ${populated[fieldName]}
</#list>

produces this output:

Boots - 2 pair
Backpacks – 1

As shown in the example, when you want to know the field names use the hash built-in ?keys. To extract only the values, use the hash built-in ?values.

parsejson

parsejson(string-exp)

Parameter

Description

string-expr

The text that contains JSON.

Converts a JSON string into sequences, hashes, and primitives.

Example 1:

${parsejson('[1,"hello",true]')?join(",")}

produces this output:

1,hello,true

Example 2:

<#assign o=parsejson("{'a':1, 'b':'Hello','c':[2,'world',false]}")>
 
${o['a']}-${o['b']}-${o['c']?join(",")}

produces this output:

1-Hello-2,world,false

NOTE: Parsing a string null ${parsejson("null")} prodces an error.

parsexml

parsexml(string-expr)

Parameter

Description

string-expr

The text that contains XML.

Converts a text string into a set of nodes.

The following example assumes that xmlField contains an XML string:

<#assign doc=parsexml(xmlField)>

rand

rand(value)

Returns a random numeric value between 0 and the given number.

randomsubset

randomsubset(list-expr, on-empty-expr, max-size-expr)

Parameter

Description

list-expr

The list from which to get the random subset.

on-empty-expr

The default value to return if the list has fewer elements than the maximum size specified.

max-size-expr

Is the maximum number of elements to return.  If the list contains a number of elements that is less than these numbers, the on-empty-expr will be used.

Returns a subset of list elements. The max-size-expr parameter specifies the maximum number of elements to return.

Example:

<#assign fruits=[“bananas”, “oranges”, “apples”, “strawberries”, “pears”>
<#list randomsubset(fruits, [], 3) as fruit>${fruit}</#list>
<#assign morefruits=[“bananas”, “oranges” >
<#list randomsubset(morefruits, fruits[0..2], 3) as fruit>${fruit}</#list>
<#list randomsubset(fruits, fruits, 6) as fruit>${fruit}<#/list>

produces this output:

oranges strawberries pears
bananas oranges apples
bananas oranges apples strawberries pears

secondadd

secondadd(date-expr, seconds-expr)

Parameter

Description

date-expr

The base date from which the offset will be calculated.

seconds-expr

The number of seconds to add or subtract.  For backward offsets, use a negative number.

Adds or subtracts the number of seconds specified by seconds-expr to a base date specified by date-expr. To subtract seconds, specify a negative number in seconds-expr.

Example 1:  Advance one second forward and back:

<#assign date="2012-12-27 13:25:03"?datetime("yyyy-MM-dd HH:mm:ss")>
${secondadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}
${secondadd(date, -1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2012-12-27 13:25:04
2012-12-27 13:25:02


Example 2: Advance one second on a date without time:

<#assign date="2012-12-27 13:25:03"?date("yyyy-MM-dd HH:mm:ss")>
${houradd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output (losing the seconds):

2012-12-27 00:00:00

Example 3:  Advance a time forward:

<#assign date="2012-12-27 13:25:03"?time("yyyy-MM-dd HH:mm:ss")>
${houradd(date, 1)?string("HH:mm:ss")}

produces this output:

13:25:04

shorturl

shorturl(link-url)

Parameter

Description

link-url

The URL to be shortened.

Attempts to shorten a given URL. A short URL is a smaller temporary representation of the provided URL. These short URLs are guaranteed to be valid for a short time frame after which they expire.

Currently only SMS campaigns return a shortened URL that allows you to keep the resulting message within the size limits of the SMS protocol. For email campaigns, this method does not shorten the URL and returns the same URL as provided.

Example:

${shorturl('http://www.google.com?q=sports+equipment')}

tracking

tracking(campaign-name)
or
tracking(campaign-name, parameter1, parameter2, parameter3, …)

Parameter

Description

campaign-name

An expression that identifies the campaign to be tracked.

parameter1, parameter2, parameter3,…

Additional values to use in the tracking of the campaign:

  • “datasourcealias.columnalias”—used for replacing fields from the recipient record using aliased fields

  • “FIELD_NAME” —used for replacing fields coming from the recipient record using the field name directly

  • “replacementname=value” —used for replacing values coming from an expression

For descriptions of these values, see the method description below.

Returns a string with parameters representing the campaign, recipient, additional parameters, and other information needed for communication with Oracle Responsys from any system.

The string is formatted as:

_ri_=ENCODEDDATA&_ei_=ENCODEDDATA

The encoded data is kept in a form required for Oracle Responsys communications. This information is particularly useful when creating links from external subscription forms to the Oracle Responsys unsubscribe servlet endpoint. For more information, see “Using tracking parameters”.

To communicate back to Oracle Responsys, both parameters must be retruned from an external system in one of the ways described below.

Creating a tracking string without additional parameters

The following example creates a set of parameters for the current campaign. This is useful for external unsubscribe form usage. This link will allow an external form to be called with unsubscription information that can be used to track unsubscriptions in Oracle Responsys.

<a href="http://www.example.com/unsubscribe?${tracking(campaign.name)}">Unsubscribe</a>
 
Creating a tracking string with additional parameters

Assuming that profile.email is provided as an alias to EMAIL_ADRESS_, the following tracking string provides an email parameter plus a parameter called MAX_AGE.

<a href="http://www.example.com/external?${tracking(campaign.name, ‘EMAIL_ADDRESS_=’ + profile.email), ‘MAX_AGE=55’}”>Weekly Add</a>

twitterjoinus

twitterjoinus(link-name, link-url)

Parameter

Description

link-name

The name of the link to be used for Twitter link tracking.

This is the name in the Link table.

The link name must be an expression without commas.

A link name and target URL (LINK_URL) are required.

link-url

The url of the link to be used as a Twitter destination.  Usually the URL of a Twitter username, or a link to a search for a hash.

This is the URL in the Link table.

A link name and target URL (LINK_URL) are required.

Creates a URL that points to a traceable link to a Twitter user or hash.

Example:

<a href="${twitterjoinus( 'FollowUsTwitter', 'https://twitter.com/search?q=%23electricyty&src=hash')}"><img src="/interact/ui/styles/images/findusontwitter.png"></a>

produces this output, with a link that will track and open the search for the indicated #electricity hash:

Standard Images

The standard Follow on Twitter image is available in Interact via the image SRC path shown in the following table. When you use this path, Interact automatically updates the SRC path to the proper Akamai URL for the given Interact account. 

Note that you must type this path exactly as it appears in the table below (uppercase file extension).

Image Path

Image

/interact/ui/styles/images/findusintwitter.png

Example:

<img src="/interact/ui/styles/images/findusontwitter.PNG">

twitterpost

twitterpost(text)

Parameter

Description

text

A string expression or constant that defines the proposed text of the tweet that will appear in the Twitter post dialog.  It should not be longer than 106 characters, since a URL is added to the message. The added URL will not exceed 34 characters. This means that the text and the link will not exceed the Twitter maximum of 140 characters.

Creates a button that will enable the user to post a tweet in their Twitter feed about the message or part of a message they received. For example, you can tweet about your current campaign or a specific event.

In addition to posting the story, you can track two additional actions: when someone clicks on the post button, and when someone clicks the shared link in Twitter. To do this, you need to create two tracking entries in the link table. The link table entries do not need to be added manually. Upon launch, the system automatically adds and maintains the entries in the link table. The Link URLs are computed for both of the tracking actions and might not be URLs that you can easily recognize.

Example:

<a href=”${twitterpost( ‘10% offer throughout the store!’)}”>Post to Twitter</a>

produces this output:

Standard image

The standard image for posting to Twitter is available in Interact via the image SRC path shown in the following table. When you use this path, Interact automatically updates the SRC path to the proper Akamai URL for the given Interact account. 

Note that you must type this path exactly as it appears in the table below (uppercase file extension).

Image Path

Image

/interact/ui/styles/images/sharetotwitter.png

Example:

<img src="/interact/ui/styles/images/sharetotwitter.PNG">

utctolocal

utctolocal(datetime)
or
utctolocal(date)

Parameter

Description

datetime

A value that contains both date and time.

The date and time is considered  as being in UTC.

date

A value that identifies a UTC date.

The date is interpreted as midnight on the given date.

Converts the datetime or date parameter from UTC time to the local datetime configured in the template.

Passing time-only variables will cause an error.

TIP: See localtoutc for the inverse operation.

Example with a date:

<#setting time_zone="America/Los_Angeles">
<#assign utc="2016-09-24"?date("yyyy-MM-dd")>
<#assign local=utctolocal(utc)>
${local?string("yyyy-MM-dd HH:mm:ss")}/${utc?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2016-09-23 17:00:00/2016-09-24 00:00:00

Example with date-time:

<#setting time_zone="America/Los_Angeles">
<#assign utc="2016-09-24 13:00:00"?datetime("yyyy-MM-dd HH:mm:ss")>
<#assign local=utctolocal(utc)>
${local?string("yyyy-MM-dd HH:mm:ss")}/${utc?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2016-09-24 06:00:00/2016-09-24 13:00:00

weekadd

weekadd(date-expr, weeks-expr)

Parameter

Description

date-expr

The base date from which the offset will be calculated.

weeks-expr

The number of weeks to add or subtract.  For backward offsets, use a negative number.

Adds or subtracts the number of weeks specified by weeks-expr to a base date specified by date-expr. To subtract weeks, specify a negative number in weeks-expr.

You cannot use fractional numbers. Fractional numbers are rounded down. For example, 1.5 becomes one, and -1.5 becomes -1. This means that specifying 1.5 weeks adds one week.

NOTE: Due technical limitations, RPL cannot always determine the type of date it receives (date only, time only, or both). For this reason, you should use the string built-ins ?datetime, ?date, and ?time to specify the date type.

Example 1: Advance one week forward and back:

<#assign date="2012-12-27 13:25:03"?datetime("yyyy-MM-dd HH:mm:ss")>
${weekadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}
${weekadd(date, -1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2013-01-03 13:25:03
2012-12-20 13:25:03

Example 2:  Advance one week on a date without time:

<#assign date="2012-12-27 13:25:03"?date("yyyy-MM-dd HH:mm:ss")>
${weekadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output (losing the time portion):

2013-01-03 00:00:00

xslt

xslt(source-node, transform-node)

Parameter

Description

source-node

A node that identifies the xml to be transformed. The node must be the root of the xml document, otherwise an error occurs.

transform-node

A node that identifies the xslt transformation to be applied to the source node.

Allows the advanced transformation of XML by using the standard XSL1.0 language. 

XSL is an industry standard transformation language used to convert XML into one of the following:

  • Plain text

  • XML

  • HTML

Use XSL only if you are familiar with its concepts.

The result of this method is a string scalar. If the transformation output specified xml as the output, and you need further access by using nodes, you might need to apply parsexml again on this result.

Example:

<#assign source=
  parsexml('<books><book name="Hamlet"/><book name="Ulyses"/></books>')>
<#assign transform=parsexml(
'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">' +
  '<xsl:output method="text"/>' +
  
  '<xsl:template match="/books/book">' +
  '[<xsl:value-of select="@name"/>]' +
  '</xsl:template>' +
'</xsl:stylesheet>')>
<#assign result=xslt(source, transform)>
${result}

produces this output:

[War and Peace][Ulyses]

The above example hardcodes the XML and the transformation directly as RPL strings, which is not best practice. As best practice, store these externally and load them from either the Content Library or remotely from an http/https source. The following example illustrates this practice. In addition, the example assumes that the transformation in sales-transform.xml produces XML and the sales information is processed in a loop:

<#assign source=parsexml(load("cms://contentlibrary/xmls/sales-info-2013-06-26.xml"))>
<#assign transform=parsexml(load("cms://contentlibrary/transforms/sales-transform.xml"))>
<#assign sales=parsexml(xslt(source, transform))>
<#list sales as sale>
    ${sale.date} - ${sale.category} - ${sale.discount}
</#list>
 

yearadd

yearadd(date-expr, years-expr)

Parameter

Description

date-expr

The base date from which the offset will be calculated.

years-expr

The number of years to add or subtract.  For backward offsets, use a negative number.

Adds or subtracts the number of years specified by years-expr to a base date specified by date-expr. To subtract years, specify a negative number in years-expr.

You cannot use fractional numbers. Fractional numbers are rounded down. For example, 1.5 becomes one, and -1.5 becomes -1. This means that specifying 1.5 years adds one year.

NOTE: Due technical limitations, RPL cannot always determine the type of date it receives (date only, time only, or both). For this reason, you should use the string built-ins ?datetime, ?date, and ?time to specify the date type.

Example 1: Advance one year forward and back:

<#assign date="2012-12-27 13:25:03"?datetime("yyyy-MM-dd HH:mm:ss")>
${yearadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}
${yearadd(date, -1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output:

2013-12-27 13:25:03
2011-12-27 13:25:03


Example 2: Advance one year on a date without time

<#assign date="2012-12-27 13:25:03"?date("yyyy-MM-dd HH:mm:ss")>
${yearadd(date, 1)?string("yyyy-MM-dd HH:mm:ss")}

produces this output (losing the time portion)

2013-12-27 00:00:00

Methods, Method Reference, Method Guide, RPL, Facebook, Twitter, Bazaarvoice, Message Digest