Omnistudio Invocation Functions

Functions that invoke or are related to invoking other functions and operations.

Omnistudio COUNTQUERY Function

Executes a SOQL query and returns the number of matching rows.

Pass a single SOQL query to the function. The query can retrieve data from only a single column (a single field).

Signature

COUNTQUERY(query)

Return Value

Integer

Parameters

Parameter

Data Type

Necessity

Description

query

SOQL Query

Required

A string that contains a valid SOQL query. In the WHERE clause, you can pass a string directly or use '{0}' to refer to an additional value passed as a string, a JSON key, or an expression.

Count Query Example
Count Query Example

Sample Account object data from database:

{
  "Account Name": "Acme Shipping",
  "Account Number": "CD451796",
  "Billing State": "GA",
  "Billing Zip": 27215
},
{
  "Account Name": "GenePoint",
  "Account Number": "CC978213",
  "Billing State": "CA",
  "Billing Zip": 94043
},
{
  "Account Name": "Edge Communications",
  "Account Number": "CD451796",
  "Billing State": "TX",
  "Billing Zip": 78767
},
{
  "Account Name": "Express Logistics",
  "Account Number": "CD736025",
  "Billing State": "MO",
  "Billing Zip": 63101
},
{
  "Account Name": "Pyramid Construction",
  "Account Number": "CD112262",
  "Billing State": "CA",
  "Billing Zip": 94087
}

Sample data:

"InputStateWest": "CA",
"InputStateEast": "PA"

Formula: COUNTQUERY("SELECT Name FROM Account WHERE BillingState = 'CA'")

Formula: QUERY("SELECT Name FROM Account WHERE BillingState LIKE '{0}'", %InputStateWest%)

Return value: 2

Formula: QUERY("SELECT Name FROM Account WHERE BillingState = 'PA'")

Formula: QUERY("SELECT Name FROM Account WHERE BillingState LIKE '{0}'", %InputStateEast%)

Return value: 0

Omnistudio FUNCTION Function

Executes a custom function defined as a method of an Apex class.

See Sample Apex Code for Custom Functions for an Apex class that defines the custom functions shown in the examples.

Signature

FUNCTION(class, method, input...)

Return Value

Any data type

Parameters

Parameter

Data Type

Necessity

Description

class

String

Required

The name of the Apex class that defines the custom function to be called. The class must define the named method and must implement the Callable interface.

method

String

Required

The name of the Apex method that defines the custom function to be called. The method must be defined in the named class.

input...

Any date type

Required

A comma-separated list of one or more values to be passed as input to the custom function. To pass a list or a JSON array as an input value, use the LIST function to pass a JSON list (an anonymous array).

The convert Custom Function Example
The convert Custom Function Example

Sample data:

"InputList": [
  "abc",
  "def",
  "ghi"
],
"ListKey": "Item"

Formula: FUNCTION('MyCustomFunctions', 'convert', LIST(%InputList%), %ListKey%)

Formula: FUNCTION('MyCustomFunctions', 'convert', LIST(InputList), ListKey)

Formula: FUNCTION('MyCustomFunctions', 'convert', LIST("abc", "def", "ghi"), 'Item')

Return value:

[
  {
    "Item": "abc"
  },
  {
    "Item": "def"
  },
  {
    "Item": "ghi"
  }
]
The replace Custom Function Example
The replace Custom Function Example

Sample data:

"InputString": "my-input-string",
"ToReplace": "-",
"ReplaceWith": "_"

Formula: FUNCTION('MyCustomFunctions', 'replace', %InputString%, %ToReplace%, %ReplaceWith%)

Formula: FUNCTION('MyCustomFunctions', 'replace', InputString, ToReplace, ReplaceWith)

Formula: FUNCTION('MyCustomFunctions', 'replace', "my-input-string", "-", "_")

Return value: "my_input_string"

The formatPhoneNumber Custom Function Example
The formatPhoneNumber Custom Function Example

Sample data: "Phone": 1234567890

Formula: FUNCTION('MyCustomFunctions', 'formatPhoneNumber', %Phone%)

Formula: FUNCTION('MyCustomFunctions', 'formatPhoneNumber', Phone)

Formula: FUNCTION('MyCustomFunctions', 'formatPhoneNumber', 1234567890)

Formula: FUNCTION('MyCustomFunctions', 'formatPhoneNumber', "1234567890")

Return value: "(123) 456-7890"

Omnistudio GENERATEGLOBALKEY Function

Generates a global key for use as an Id in a data pack.

Signature

GENERATEGLOBALKEY(prefix)

Return Value

String

Parameters

Parameter

Data Type

Necessity

Description

prefix

String

Optional

A string to be prepended to the global key that the function returns. The function inserts a - (hyphen) between the prefix and the global key.

No Prefix Example
No Prefix Example

Formula: GENERATEGLOBALKEY()

Return value: "15c4ec2d-be7a-4f54-b342-652fdf159f30"

Prefix Example
Prefix Example

Formula: GENERATEGLOBALKEY("SUB")

Return value: "SUB-f72bd2ca-a03b-48e3-af30-485efb4fa4d9"

Omnistudio QUERY Function

Executes a SOQL query and returns a JSON list of results.

Pass a single SOQL query to the function. The query can retrieve data from only a single column (a single field).

To get the size of the JSON list that's returned, first use the ISBLANK function to test for an empty list. If the list is not empty, use the LISTSIZE function to return its size. Call the functions in separate Set Values actions or Data Mapper functions. (The COUNTQUERY function returns the number of matching rows from a query.)

Signature

QUERY(query)

Return Value

JSON list

Parameters

Parameter

Data Type

Necessity

Description

query

SOQL Query

Required

A string that contains a valid SOQL query. In the WHERE clause, you can pass a string directly or use '{0}' to refer to an additional value passed as a string, a JSON key, or an expression.

Query with Results Example
Query with Results Example

Sample Account object data from database:

{
  "Account Name": "Acme Shipping",
  "Account Number": "CD451796",
  "Billing State": "GA",
  "Billing Zip": 27215
},
{
  "Account Name": "GenePoint",
  "Account Number": "CC978213",
  "Billing State": "CA",
  "Billing Zip": 94043
},
{
  "Account Name": "Edge Communications",
  "Account Number": "CD451796",
  "Billing State": "TX",
  "Billing Zip": 78767
},
{
  "Account Name": "Express Logistics",
  "Account Number": "CD736025",
  "Billing State": "MO",
  "Billing Zip": 63101
},
{
  "Account Name": "Pyramid Construction",
  "Account Number": "CD112262",
  "Billing State": "CA",
  "Billing Zip": 94087
}

Sample data:

"InputStateWest": "CA",
"InputStateEast": "PA"

Formula: QUERY("SELECT Name FROM Account WHERE BillingState = 'CA'")

Formula: QUERY("SELECT Name FROM Account WHERE BillingState LIKE '{0}'", %InputStateWest%)

Return value: [ "GenePoint", "Pyramid Construction" ]

Formula: LISTSIZE(QueryResult)

Return value: 2

Query with No Results Example
Query with No Results Example

Formula: QUERY("SELECT Name FROM Account WHERE BillingState = 'PA'")

Formula: QUERY("SELECT Name FROM Account WHERE BillingState LIKE '{0}'", %InputStateEast%)

Return value: {}

Formula: LISTSIZE(QueryResult)

Return value: 1

Formula: IF(ISBLANK(QueryResult), 0, LISTSIZE(QueryResult))

Return value: 0

Query with Count Query Example
Query with Count Query Example

Formula:

IF(COUNTQUERY("SELECT Name FROM Account WHERE BillingState = 'CA'"),
  LIST(QUERY("SELECT Name FROM Account WHERE BillingState = 'CA'")),
  0)

Return value: [ "GenePoint", "Pyramid Construction" ]

Formula:

IF(COUNTQUERY("SELECT Name FROM Account WHERE BillingState = 'PA'"),
  LIST(QUERY("SELECT Name FROM Account WHERE BillingState = 'PA'")),
  0)

Return value: 0

Omnistudio GLOBALAUTONUMBER Function

Generates a unique number as per the configurations you define through the Omni Global Auto Number page.

For more information on defining your own numbering system, see Set Up Omni Global Auto Numbers.

Signature

GLOBALAUTONUMBER("GlobalAutoNumber"), GLOBALAUTONUMBER("Name")

Return Value

String

Parameters

Parameter

Data Type

Necessity

Description

GlobalAutoNumber

String

Optional

A global auto number name, which you created on the Omni Global Auto Number page. When you call this function without any value as an input, the value GlobalAutoNumber is automatically set. If there’s data associated with the name, the function generates a number as per this data. If not, an error is thrown.

No Name Specified Example
No Name Specified Example

Formula: GLOBALAUTONUMBER()

Return value: "OS-12345"

Example with the Name "Loan Application Number"
Example with the Name "Loan Application Number"

Formula: GLOBALAUTONUMBER("Loan Application Number")

Return value: "LI-6298525"