Omniscript Functions (Managed Package)

For the managed package runtime, you can add functions to the Aggregate and Formula elements in Omniscripts.

Managed Package app icon This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.

For a list of functions for Omnistudio Data Mappers and Integration Procedures, see Function Reference (Managed Package).

For information on adding Formula or Aggregate elements to your Omniscript, see Create a Formula or Aggregate in an Omniscript (Managed Package). To view a list of supported formula operators that can be used with the Formula element, see Supported Formula Operators (Managed Package).

The tables below detail the different available Omniscript functions and how they work.

Function Name

Example

Details

ABS(number)

ABS(%Friends%) == 6.52534

Returns the absolute value.

BOOLEAN(value)

 

Returns true or false.

CURRENCY(value)

 

Returns value formatted for currency. 12345 would display as 12,345.

INTEGER(value)

INTEGER(%Friends%) == 6

INTEGER("12.5") == 12

Converts the number given into an integer with no decimal places. Does not round the number up. Also accepts a string.

NULL

 

Renders an object's value null.

NUMBER(value)

NUMBER(%Friends%) == 128

Converts a string into a number.

POW(number, exponent)

POW(%Friends%, 3) == 274.625

Returns exponent value.

RANDOM()

RANDOM()

Returns a random number between zero and one. This function is commonly used in A/B testing. The RANDOM() function does not accept parameters.

ROUND(number, decimalPlaces)

ROUND(%Friends%, 3) == 6.525

Rounds number to certain defined number of decimal places.

Function Name

Example

Details

AND();

IF((%reset%="Yes" AND( %reboot%="Yes")), "Closed", "Escalated")

Logical operator that performs a function if all conditions are both met.

COUNTIF(values, expression_or_value)

COUNTIF(%MyArray%, >10)

Returns a count of the number of repeated elements if a condition is met.

EQUALS( Field_Name, 'Condition')

IF(

EQUALS(%Department%,'401(k)'),

"Then Result",

"Else Result"

)

The EQUALS function is used when comparing a field to a particular value or another field.

IF(EXPRESSION,THEN, ELSE)

IF((%reset%="Yes" || %reboot%="Yes"), "Closed", "Escalated")

If EXPRESSION evaluates to True, THEN is returned, otherwise ELSE is returned.

OR()

IF((%reset%="Yes" OR( %reboot%="Yes")), "Closed", "Escalated")

 

SUMIF(values, expression_or_value)

SUMIF(%MyArray%, >5)

Returns the sum of all comma-separated elements and value if a condition is met.

Function Name

Example

Details

CASE(value, $CASE)

CASE(%Name%, UPPER) == "TONY JONES"

CASE(%Name%, LOWER) == "tony jones"

CASE(%Name%, SENTENCE) == "Tony jones"

CASE(%Name%, TITLE) == "Tony Jones"

Changes case based on $CASE type. $CASE must be LOWER, UPPER, SENTENCE, or TITLE.

CONCATENATE(value1, value2, ..., valueN)

CONCATENATE(%FirstName%, " ", %LastName%) == "Tony Jones"

Concatenates the elements/strings together into a single string.

CONTAINS(input_string,value)

CONTAINS(%FirstName%, "Tony") == True

Evaluates if a value is contained within a string.

SPLIT(text, splitToken, limit);

SPLIT("Tony Jones", " ", 2) == "Tony", "Jones"

 

STRING(value)

STRING(%Friends%) == "6.5"

Converts any value into a String.

SUBSTRING(text, startIndex, endIndex)

SUBSTRING("Substring!", 3, 9) == "string"

Extracts the characters from a string between two specified indexes and returns the value.

Function Name

Example

Details

AGE(dateOfBirth)

AGE(%Birthdate%) == 7

Returns an age (in years) with the given date of birth on today's date. Use the Date element.

AGEON(dateOfBirth, futureDate)

AGEON(%Birthdate%,"07-09-2024") == 16

The age of someone (in years) with the given date of birth on a future date. Use the Date element.

DATE(value)

DATE(%DOB%) == Wed Jul 19 1978 16:00:00 GMT-0700 (PDT)

Use a Date element. Returns full JavaScript format.

DATEDIFF(date1, date2)

DATEDIFF(%DOB%,%TODAY%) == 13559

The difference between 2 dates in days. The value will always be a positive integer. Use the Date element.

DAYOFMONTH(date)

DAYOFMONTH(%TODAY%) == 2

Returns the day of the month. Use the Date element.

DAYOFWEEK(date)

DAYOFWEEK(%TODAY%) == 4

Returns the day of the week as an integer. Monday is 1, Sunday is 7.

HOUR(date)

 

Return the current hour according to local time.

MINUTE(date)

 

Return the current minute according to local time.

MOMENT()

MOMENT(%policyStartDate%).add(1, 'year').subtract(1, 'day')

Returns the moment object of Moment.js

This can be used to perform complex date formatting, calculations, manipulation, comparisons, etc. The MOMENT() function must contain parameters, for example, MOMENT(NOW()). Appending .calendar() to this function is a recommended best practice.

MONTH(date)

MONTH(%TODAY%) == 9

The month of the year as an integer. Use the Date element.

NOW()

NOW() == Thu Aug 27 2019 16:32:00 GMT -0700 (PDT)

Returns current date and time in full JavaScript format. Milliseconds are always set to 0.

The $Vlocity.NOW environment variable applies the user or org time zone, while the NOW() function applies UTC time.

TODAY()

TODAY() == Thu Aug 27 2019 00:00:00 GMT -0700 (PDT)

Returns today's date. The time is always set to midnight

Known issue: When the TODAY() function is used in Set Values, it returns the previous date. Two workarounds exist: Use TODAY() + "", or use MOMENT() or TIMESTAMP() instead of TODAY().

YEAR(date)

YEAR(%TODAY%) == 2019

Returns the year of the date as an integer. Use the Date element.

Function Name

Example

Details

ARRAY(value1, value2, ..., valueN)

ARRAY(%Child1%,%Child2%,

%Child3%,%Child4%) == [4,3,1,2]

Returns an array of the value of the elements.

AVERAGE(array)

AVERAGE(%Age%) == 2.5

Aggregate: returns the average mean value of the numbers provided. Use a repeating element.

AVERAGE(value1, value2, ..., valueN)

AVERAGE(%Child1%,%Child2%,

%Child3%,%Child4%) == 2.5

Returns the average mean value of the numbers provided.

COUNT(array)

COUNT(%Age%) == 4

Aggregate: Returns a count of the number of repeated elements.

EXISTS(array_or_value, expression_or_value)

EXISTS([%FirstName%,%LastName%], "Tony") == true

Returns true if the given value exists in one or more elements. For Aggregate, enter the name of a repeating element—for example EXISTS(%FirstName%,"Tony"), where FirstName is repeatable.

MAX(array)

MAX(%AGE%) == 4

Aggregate: Returns the largest value in the numbers provided. Use a repeating element.

MAX((value1, value2, ..., valueN)

MAX(%Child1%,%Child2%,

%Child3%,%Child4%) == 4

Returns the largest value in the group of elements provided.

MIN(array)

MIN(%AGE%) == 1

Aggregate: returns the smallest value in the numbers provided. Use a repeating element.

MIN((value1, value2, ..., valueN)

MIN(%Child1%,%Child2%,

%Child3%,%Child4%) == 1

Returns the smallest value in the group of elements provided.

SUM(array)

SUM(%AGE%) == 10

Aggregate: returns the sum of all values in the repeatable element.

SUM(value1, value2, ..., valueN)

SUM(%Child1%,%Child2%,

%Child3%,%Child4%) == 10

Returns the sum of all comma-separated elements and values.

Note that when you use a Formula input in an Omniscript with the SUM formula, the Expression text box defaults the precision of decimal values to two. This occurs even if you specify the desired number of decimal values in your formula. For instance, if you use the formula ROUND(SUM(4.216546546,5.55463551),7), the result is 9.77 instead of 9.7711821. To get precise decimal points, use the ROUND formula with a + (plus) sign instead. For instance, you can use the formula ROUND(4.216546546+5.55463551,7) instead of the one in the previous example to get the desired precision.