call (855) 387-8288
Trackdrive

Expressions & Functions

Expressions and functions allow for expanded functionality with leads, webhooks, postbacks, and calls. Functions can be nested (one formula within another) to create complex calculations.

Formula Example

Expressions

Expressions are combinations of functions that can be evaluated anywhere token replacement is available. The available expression types are String, Integer, Float, and Time. The function arguments for each type of expression will be coerced to that type when evaluated. EG: Integer type would coerce "15.24" to 15

[!String!  SOME_FUNCTION([first_name])  !!]
[!Integer!  SOME_FUNCTION([amount], [other_amount])  !!]
[!Float!  SOME_FUNCTION([currency_token])  !!]
[!Time!  SOME_FUNCTION([date_token], [another_date_token])  !!]

Example Data

Given the following example data, the expressions below would output the values as indicated by =>

{
  "first_name": "John",
  "last_name": "Smith",
  "birth_year": "1977",
  "yob": 2012,
  "mortgage_amount": 65000,
  "debt_amount": 8283.25,
  "started_at_utc": "2020-06-21 22:35:12 UTC"
}

String Example

Convert function arguments into strings and evaluate the expression.

[!String! ALPHANUMERIC_DASH("[first_name] [last_name]") !!]
=> john-smith

Integer Example

Convert function arguments into integers and evaluate the expression.

[!Integer! MIN([birth_year], [yob]) !!]
=> 1977

Decimal Example

Convert function arguments into decimals and evaluate the expression.

[!Float! SUM([debt_amount], [mortgage_amount]) !!]
=> 73283.25

Time Example

Convert function arguments into Time and evaluate the expression.

[!Time! DATE_FORMAT(DATE_ADD([started_at_utc], 86400), "%Y-%m-%d %M-%S") !!]
=> "2020-06-22T18:35:12"

Functions

alphanumeric_dash(value)

string

Returns a copy of the receiver with only alphanumeric characters (0-9 and a-z A-Z) and spaces converted to dashes. Leading and trailing spaces are removed.

Argument Required Info
value Required
ALPHANUMERIC_DASH(" ./;!!!]  hello waffle world!@#$%^&*($)  ")
=> "hello-waffle-world"

alphanumeric_underscore(value)

string

Returns a copy of the receiver with only alphanumeric characters (0-9 and a-z A-Z) and spaces converted to underscores. Leading and trailing spaces are removed.

Argument Required Info
value Required
ALPHANUMERIC_UNDERSCORE(" ./;!!!]  hello waffle world!@#$%^&*($)  ")
=> "hello_waffle_world"

date_add(value, seconds)

string

The date_add function adds seconds to a date.

Argument Required Info
value Required The date that will be modified.
seconds Required The seconds that will be added.
DATE_ADD([started_at_utc], 86400)
=> "2020-06-29 11:34:25 -0400"

date_format(value, format)

string

Format a date

Argument Required Info
value Required The date that will be modified. EG '2020-06-29 11:22:57 -0400'
format Required Specifies the format for the date. The following characters can be used.

Date (Year, Month, Day):
%Y - Year with century
%y - year % 100 (00..99)
%m - Month of the year, zero-padded (01..12)
%B - The full month name (``January'')
%b - The abbreviated month name (``Jan'')
%d - Day of the month, zero-padded (01..31)
%j - Day of the year (001..366)

Time
%H - Hour of the day, 24-hour clock, zero-padded (00..23)
%I - Hour of the day, 12-hour clock, zero-padded (01..12)
%P - Meridian indicator, lowercase (``am'' or ``pm'')
%p - Meridian indicator, uppercase (``AM'' or ``PM'')
%M - Minute of the hour (00..59)
%S - Second of the minute (00..59)
%L - Millisecond of the second (000..999)
%N - Fractional seconds digits, default is 9 digits (nanosecond)
%z - Time zone as hour and minute offset from UTC (e.g. +0900)

Weekday
%A - The full weekday name (``Sunday'')
%a - The abbreviated name (``Sun'')
%u - Day of the week (Monday is 1, 1..7)
%w - Day of the week (Sunday is 0, 0..6)

Seconds since the Unix Epoch
%s - Number of seconds since 1970-01-01 00:00:00 UTC.
%Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
DATE_FORMAT([started_at_utc], "%Y-%m-%d %M-%S")
=> "2020-06-22T18:35:12"

date_parse(value)

string

The date_parse function is a natural language date/time parser.

Argument Required Info
value Required The date or natural language expression.

Simple Examples
thursday
november
summer
friday 13:00
mon 2:35
4pm
yesterday
today
tomorrow
last week
next week

Complex Examples
3 years ago
a year ago
5 months from now
7 hours ago
7 days from now
in 3 hours

Specific Dates & Times
22nd of june at 8am
1979-05-27 05:00:00
03/01/2012 07:25:09.234567
2013-08-01T19:30:00.345-07:00
2013-08-01T19:30:00.34-07:00
DATE_PARSE("30 days from now")
=> "2020-07-29 15:42:57 UTC"

downcase(value)

string

Returns a copy of the receiver with all letters converted to lowercase.

Argument Required Info
value Required
DOWNCASE("HELLO World")
=> "hello world"

split(value, pattern, index)

string

Divides value into substrings based on a delimiter, returning the substring at index.

Argument Required Info
value Required The text that will be modified.
pattern Required The pattern is a String. Its contents are used as the delimiter when splitting str. If pattern is a single space, str is split on whitespace, with leading and trailing whitespace and runs of contiguous whitespace characters ignored.
index Required Index is the index of the split substrings that will be returned. Examples:

SPLIT("John Andrew Smith", ' ', 0) would return "John"
SPLIT("John Andrew Smith", ' ', 1) would return "Andrew"
SPLIT("John Andrew Smith", ' ', 2) would return "Smith"
SPLIT("2019-01-12", '-', 1) would return "01"
SPLIT("John Smith", " ", 1)
=> "Smith"

strip(value)

string

Returns a copy of the receiver with leading and trailing whitespace removed.

Whitespace is defined as any of the following characters: null, horizontal tab, line feed, vertical tab, form feed, carriage return, space.

Argument Required Info
value Required
STRIP("    hello world   ")
=> "hello world"

substring(value, start, length)

string

A substring is a range of characters within an existing string.

Argument Required Info
value Required The text that will be modified
start Required The position where to start the extraction. First character is at index 0.
length Required The number of characters to extract. Pass -1 to extract the rest of the string.
SUBSTRING("hello world", 6, -1)
=> "world"

titleize(value)

string

Returns a copy of the receiver with the first letter of each word capitalized.

Argument Required Info
value Required
TITLEIZE("  hello world  ")
=> "  Hello World  "

upcase(value)

string

Returns a copy of the receiver with all letters converted to uppercase.

Argument Required Info
value Required
UPCASE("Hello World")
=> "HELLO WORLD"

usa_zip_code(value)

string

Returns a copy of the receiver with only the first 5 digits preserved.

Argument Required Info
value Required
USA_ZIP_CODE("USA 90210 OR")
=> "90210"

min(*values)

numeric

Get the smallest numeric value from the set of passed arguments.

Argument Required Info
*values Required This function accepts an unlimited number of numeric values.
MIN(1,2,3,4)
=> 1

max(*values)

numeric

Get the largest numeric value from the set of passed arguments.

Argument Required Info
*values Required This function accepts an unlimited number of numeric values.
MAX(1,2,3,4)
=> 4

sum(*values)

numeric

Get the sum of the numeric values.

Argument Required Info
*values Required This function accepts an unlimited number of numeric values.
SUM(1,2,3,4)
=> 10

avg(*values)

numeric

Get the average of the passed numeric values.

Argument Required Info
*values Required This function accepts an unlimited number of numeric values.
AVG(1,2,3,4)
=> 2.5

count(*values)

numeric

Count the passed values.

Argument Required Info
*values Required This function accepts an unlimited number of numeric values.
COUNT(1,2,3,4)
=> 4

round(value, precision)

numeric

Returns float rounded to the nearest value.

Argument Required Info
value Required The value to be rounded. EG:
ROUND(8.8) => 9
ROUND(8.2) => 8
precision Optional The precision to be used. EG:
ROUND(8.75, 1) => 8.8
ROUND(8.2)
=> 8

rounddown(value, precision)

numeric

Returns float rounded down to the nearest value.

Argument Required Info
value Required The value to be rounded. EG:
ROUND(8.8) => 8
precision Optional The precision to be used. EG:
ROUND(1.234, 2) => 1.23
ROUNDDOWN(1.234)
=> 1

roundup(value, precision)

numeric

Returns float rounded up to the nearest value.

Argument Required Info
value Required The value to be rounded. EG:
ROUND(8.8) => 9
precision Optional The precision to be used. EG:
ROUND(1.234, 2) => 1.24
ROUNDUP(1.234)
=> 2
Waves
Contact TrackDrive

Questions ?

We’re here to help. Call us and speak with a Voice Marketing Cloud Specialist.

Call : (855) 387-8288
Request A Demo

Request A Demo.

See how you can improve your marketing and the customer experience with the Voice Marketing Cloud.

Request a demo