Formulas

In an you can apply Formulas to extract, format or process your data as they flow in the workflow. It’s as same as working with a spreadsheet software such as MS Excel, where you use formulas (built-in functions)) like sum(…), power(…), concatenate(…) …etc. In the same way, you can use formulas in that performs following functionalities.

  • Concatenate first & last name to create full name. e.g. contact({{#firstName}}, {{#lastName}}). Here {{#firstName}} & {{#lastName}} are two macros that resolve into firstName & lastName values that comes from the previous step of your ICApp each time it’s executed.
  • When using email as an action, you can add date & time to your email content to specify date(), time() functions.

String Functions

Function Description
to_lower( s ) Convert a string to lower case
to_upper( s ) Convert a string to upper case
to_caps( s ) Capitalize a string
split( s, regex) Split the string around the matches. e.g. {{@split( “Freeman”, “e” )[0]}} -> “Fr”
trim( s ) Remove leading and trailing white spaces from a string
to_str( s ) Convert Numbers, JSON, Boolean values to their string form
is_empty( s ) Check if a string is empty
length( s ) Returns length of the string
compare( s1, s2) Compares two strings s1 & s2 lexicographically (alphabetical order of the dictionary). returns 0 => if equals, 1 => if s1 > s2, -1 => if s1 < s2
equals( s1, s2) Compares if s1 & s2 are exactly matches. Match is case sensitive.
concat( s1, s2) Concatenate two strings
contains( s, search) Check if the string contains the specified ‘search’ strings
matches( s, regex) Check if the string matches the given regex
mstart( s, prefix) Check if a string starts with the given prefix
mend( s, suffix) Check if a string ends with the given suffix
substr( s, start, end) Get a substring from start index to end index, note that first character of the string is at 0th index.
extract( s, regex) Extract all matching strings, for a given regex, in the string given as first argument to the function and produce the results as a json array
replace( s, what, rep) Replace ALL the occurrences of what found in the given string with the rep string
replace_1st( s, what, rep) Replace First occurrence of what found in the given string with the rep string
replace_rx( s, regex, rep) Replace ALL the occurrences that matches with the given regex, found in the given string, with the rep string

Date Functions

All date & time functions (unless you specify a timezone) uses UTC to avoid any regional differences.

Function Description
date() Today’s date as at UTC
time() Time as at UTC
time24h() Time as at UTC in 24h format
datetime() Date & time as at UTC
timestamp() Timestamp in number of seconds from the epoch of 1970-01-01T00:00:00Z
date_at( tz ) Today’s date at a given timezone
time_at( tz ) Time at a given timezone
datetime_at( tz ) Date & time at a given timezone
to_datetime( s ) Convert ISO 8601 date time string to a format suitable for processing, e.g. 2022-02-03T12:15:30+01:00
ex_date( s ) Extract date from ISO 8601 format string. e.g. 2022-02-03T12:15:30+01:00 => 2022-02-03
ex_time( s ) Extract time from ISO 8601 format string. e.g. 2022-02-03T12:15:30+01:00 => 12:15:30

Math Functions

Function Description
abs( n ) Get absolute value of a Number
ceiling( n ) Get the least integer number greater than or equal to the given number
floor( n ) Get the greatest integer less than or equal to the given number
max( x, y) Get the greater of the two values x & y
min( x, y) Get the smallest of the two values x & y
pow( x, y) Get x value raised to the power of y value
round( n ) Get rounding off value for the given argument
sum( x, y ) Get summation of two x & y
to_num( s ) Convert string value to it’s number format number

JSON Functions

Function Description
is_empty( ) Check if the JSON is empty
length( ) Returns length of the string
merge( , ) Merge two or more JSON objects or arrays together.
to_json( obj ) Convert JSON to a it’s string form - i.e. stringify
setvalue( obj, key, value) Set a value of a JSON attribute.

Other Functions

Function Description
uuid() Generate random UUID.
random_id() Generate random ID
random_str(10) Generate random string of a given length
enc_base64( ) Encode a string with Base 64
dec_base64( ) Decode a Base 64 string to it’s orignal string
enc_url( str ) Encode a given URL fragment to a URL safe form
dec_url( ) Decode a encoded URL into orinal string
md5( ) Calculate MD5 of a string
sha256( ) Create SHA256 hash of a string
sha512( ) Create SHA512 hash of a string




Regular Expressions Reference

x       The character x
xy      The character x followed by y and so on...
.       Match any single character except newline. When in [] class (see below) it means period.
-       Range in a Character class e.g. [a-z] or [0-9]
[]      Character class. e.g.
            [abc]       a, b, or c (simple class)
            [^abc]      Any character except a, b, or c (negation)
            [a-zA-Z]    a through z or A through Z, inclusive (range)
            [0-9]       0 through 9, inclusive (range)

\       Escape the next character.  e.g. \\ The backslash character
^       The beginning of a line. 
$       The end of a line. 
|       Alternation e.g. x|y  means either x or y.
()      Grouping 
*       0 or more times
+       1 or more times
?       0 or 1 times
{n}     exactly n number of times
{n,}    at least n times
{n,m}   at least n but not more than m times

\d	A digit: [0-9]
\D	A non-digit: [^0-9]
\s	A whitespace character: [\t\n\f\r]
\S	A non-whitespace character: [^\s]
\w	A word character: [a-zA-Z_0-9]
\W	A non-word character: [^\w]
Last modified October 29, 2024