Workflow Expressions
Expressions are used to evaluate conditions, map data, and more.
NCalc Expressions
NCalc expressions are used to evaluate conditions. NCalc expressions are a superset of Excel formulas. NCalc expressions can be used to evaluate conditions, map data, and more.
More information about NCalc expressions can be found NCalc GitHub.
Variable in Expressions
Workflow inputs can be accessed in expressions using square brackets. For example, to access the orderId
input, use [orderId]
.
Nested inputs can be accessed using dot notation. For example, to access the orderId
input of the Order
input, use [Order.orderId]
.
Functions
List of functions that can be used in expressions:
All(Array, Condition)
Any(Array, Condition)
Sum(Array, Property?)
Count(Array)
isNullOrEmpty(Value)
base64(Value)
format(Format, Value1, Value2, ...)
replace(Value, Pattern, Replacement)
lower(Value)
upper(Value)
left(Value, Length)
right(Value, Length)
first(Array, Property?)
last(Array, Property?)
join(Array, Template, Separator?)
contains(Value, Substring)
parseAddress(AddressString)
removeEmpty(Value)
All(Array, Condition)
The All
function can be used to check if all items in a collection match a condition. The All
function takes two parameters: the collection to check and the condition to check for.
Condition should check if the current item matches the condition. The current item can be accessed using the each
variable.
Example:
all([Order.Commodities], [each.status] = 'Shipped') = true
Any(Array, Condition)
The Any
function can be used to check if a collection contains any items that match a condition. The Any
function takes two parameters: the collection to check and the condition to check for.
Condition should check if the current item matches the condition. The current item can be accessed using the each
variable.
Example:
any([Order.Commodities], [each.status] = 'Shipped') = true
Sum(Array, Property?)
The Sum
function can be used to sum the values of a property in a collection. The Sum
function takes two parameters: the collection to sum and the property to sum.
If the property is not specified, the Sum
function will sum the values in the collection.
Example:
sum([Order.Commodities], [each.price])
Count(Array)
The Count
function can be used to count the number of items in a collection. The Count
function takes one parameter: the collection to count.
Example:
count([Order.Commodities])
isNullOrEmpty(Value)
The isNullOrEmpty
function can be used to check if a value is null or empty. The isNullOrEmpty
function takes one parameter: the value to check.
Example:
isNullOrEmpty([Order.Customer.Email]) = false
base64(Value)
The base64
function can be used to convert a string to base64. The base64
function takes one parameter: the string to convert.
Example:
base64('Hello World') = 'SGVsbG8gV29ybGQ='
format(Format, Value1, Value2, ...)
The format
function can be used to format a string. The format
function takes a format string and a list of values to format.
Example:
format('Hello {0}', 'World') = 'Hello World'
format('{0:F1}', [number]) = '123.5'
format('{0:F2}', [number]) = '123.46'
format('{0:#.00}', [number]) = '123.46'
replace(Value, Pattern, Replacement)
The replace
function can be used to replace a pattern in a string. The replace
function takes three parameters: the string to replace, the pattern to replace, and the replacement string.
Example:
replace('Hello World', 'World', 'Universe') = 'Hello Universe'
lower(Value)
The lower
function can be used to convert a string to lowercase. The lower
function takes one parameter: the string to convert.
Example:
lower('Hello World') = 'hello world'
upper(Value)
The upper
function can be used to convert a string to uppercase. The upper
function takes one parameter: the string to convert.
Example:
upper('Hello World') = 'HELLO WORLD'
left(Value, Length)
The left
function can be used to get the leftmost characters of a string. The left
function takes two parameters: the string to get the leftmost characters from and the number of characters to get.
Example:
left('Hello World', 5) = 'Hello'
right(Value, Length)
The right
function can be used to get the rightmost characters of a string. The right
function takes two parameters: the string to get the rightmost characters from and the number of characters to get.
Example:
right('Hello World', 5) = 'World'
first(Array, Property?)
The first
function can be used to get the first item in a collection. The first
function takes two parameters: the collection to get the first item from and the property to get from the first item.
Accessing the first item of a collection can be done using the first
variable.
Example:
first([Order.Commodities], [item.status]) = 'Shipped'
last(Array, Property?)
The last
function can be used to get the last item in a collection. The last
function takes two parameters: the collection to get the last item from and the property to get from the last item.
Accessing the last item of a collection can be done using the item
variable.
Example:
last([Order.Commodities], [item.status]) = 'Shipped'
join(Array, Template, Separator?)
The join
function can be used to join an array into a string. The join
function takes three parameters: the array to join, the template to use for each item, and the separator to use between items.
Example:
join([Order.Commodities], [each.quantity] + 'x' + [each.description], ', ') = '1 x Item 1, 2 x Item 2, 3 x Item 3'
contains(Value, Substring)
The contains
function can be used to check if a string contains a substring. The contains
function takes two parameters: the string to check and the substring to check for.
contains('Hello World', 'World') = true
parseAddress(AddressString)
The parseAddress
function can be used to parse an address string into an address object. The parseAddress
function takes one parameter: the address string to parse.
parseAddress('123 Main St, Anytown, US') = {
road: 'Main St',
houseNumber: '123',
unit: '',
city: 'Anytown',
state: 'CA',
postalCode: '12345',
country: 'US'
}
removeEmpty(Value)
The removeEmpty
function can be used to remove empty strings from a collection. The removeEmpty
function takes one parameter: the collection to remove empty strings from.
Example:
string[] items = ['Item 1', '', null, 'Item 3'];
removeEmpty([items]) = ['Item 1', 'Item 3']