Appearance
Expressions ​
Expressions are powerful rules that dictate how the value for each Output Name is generated. The Orisha Commerce Platform (OCP) utilizes the NCalc library for evaluating these expressions, supporting a wide range of mathematical and logical operations.
Variables ​
| Parameter | Description |
|---|---|
[Name] | The name of the item (locale text field, nullable). |
[FamilyCode] | The family code of the item (text field, nullable). |
[ItemCode] | The code of the item (text field). |
[UomCode] | The unit of measure code of the item (text field). |
[VatTariff] | The VAT tariff of the item (Normal, Low1, Low2, SuperLow, ParkingTariff, NoVat). |
[Images] | The images of the item (array of objects). |
[Stocks] | The stocks of the item (array of objects). |
[RestockOrders] | The restock orders of the item (array of objects). |
Attributes ​
You can access an item's attributes using the [Attributes.(...)] accessor, for example [Attributes.OLB-Color]. Attributes can have different types.
When accessing an attribute through an expression, the returned value is always an array. This is because an attribute like materials can hold multiple values (e.g., stone, wood, etc.).
If you only need a single value, you can use the firstOrDefault expression function to retrieve the first one.
📦 any ​
Determines if any items in a list match a condition. If no condition is provided, determines if the list contains any items.
| Parameter | Type | Description |
|---|---|---|
| list* | object[] | The list |
| predicate | string | A string to represent the value to be evaluated |
| lambda | string | The lambda expression |
Examples
| Expression | Result |
|---|---|
any((1, 2, 3)) | true |
any(()) | false |
any((1, 2, 3), 'x', 'x > 2') | true |
any((1, 2, 3), 'x', 'x > 3') | false |
📦 coalescing ​
Returns the first non-null value
| Parameter | Type | Description |
|---|---|---|
| parameter1* | object | |
| parameter2* | object | |
| parameter3 | object | |
| parameter4 | object | |
| parameter5 | object | |
| parameter6 | object | |
| parameter7 | object | |
| parameter8 | object | |
| parameter9 | object | |
| parameter10 | object |
Examples
| Expression | Result |
|---|---|
coalescing(null, 'Hello', 'World') | 'Hello' |
coalescing('Hello', 'World') | 'Hello' |
📦 concat ​
Concatenate lists.
| Parameter | Type | Description |
|---|---|---|
| list1* | object[] | Collection. |
| list2* | object[] | Collection. |
| list3 | object[] | Additional collections. |
| list4 | object[] | Additional collections. |
| list5 | object[] | Additional collections. |
Examples
| Expression | Result |
|---|---|
concat(list('a', 'b'), list('c')) | list('a', 'b', 'c') |
📦 contains ​
Determines whether a string contains a specified substring (case-sensitive).
| Parameter | Type | Description |
|---|---|---|
| input* | string | The original string. |
| value* | string | The substring to search for. |
Examples
| Expression | Result |
|---|---|
contains('Hello World', 'World') | true |
contains('Hello World', 'world') | false |
📦 count ​
Counts all the elements in the list.
| Parameter | Type | Description |
|---|---|---|
| list* | object[] | The original list. |
Examples
| Expression | Result |
|---|---|
count(list(1, 2, 3)) | 3 |
📦 displayProperty ​
Returns an object with the specified title and value. The title is a locale value. When the value is null, the function returns null.
| Parameter | Type | Description |
|---|---|---|
| title* | string | |
| value* | object |
Examples
| Expression | Result |
|---|---|
displayProperty('Title', 'Value') | Object with title and value |
displayProperty('Title', null) | Null |
displayProperty(multilang('en-US', 'Color'), 'Blue') | Object with title and value |
📦 distinct ​
Creates a distinct list from the provided collection.
| Parameter | Type | Description |
|---|---|---|
| list* | object[] | The original list. |
Examples
| Expression | Result |
|---|---|
distinct(1, 2, 2) | [1, 2] |
📦 elementAt ​
Returns the element at the specified index in a collection.
| Parameter | Type | Description |
|---|---|---|
| collection* | object[] | The collection to retrieve the element from. |
| index* | System.Int32 | The index of the element to retrieve. |
Examples
| Expression | Result |
|---|---|
elementAt([1, 2, 3], 1) | 2 |
elementAt(['a', 'b', 'c'], 0) | 'a' |
elementAt([1, 2, 3], 5) | null |
📦 endsWith ​
Determines whether a string ends with a specified suffix (case-sensitive).
| Parameter | Type | Description |
|---|---|---|
| input* | string | The original string. |
| value* | string | The suffix to check for. |
Examples
| Expression | Result |
|---|---|
endsWith('Hello World', 'World') | true |
endsWith('Hello World', 'world') | false |
📦 firstOrDefault ​
Returns the first item in a list or null if the list is empty.
| Parameter | Type | Description |
|---|---|---|
| list* | object[] | The original list. |
Examples
| Expression | Result |
|---|---|
firstOrDefault(list(1, 2, 3)) | 1 |
firstOrDefault(list()) | NULL |
📦 getProperty ​
Gets a property from an object. Supports nested property paths using dot notation (e.g., "Address.Street"). If the property cannot be found, returns the default value if provided.
| Parameter | Type | Description |
|---|---|---|
| input* | object | The object to get the property from. |
| propertyName* | string | The name or path of the property to get (supports dot notation for nested properties). |
| defaultValue | object | The default value to return if the property cannot be found. |
Examples
| Expression | Result |
|---|---|
getProperty(object, "Address.Street") | value |
📦 iif ​
Returns one of two values depending on the evaluation of a boolean expression.
| Parameter | Type | Description |
|---|---|---|
| condition* | object | The boolean expression to evaluate. |
| trueValue* | object | The value to return if the condition is true. |
| falseValue* | object | The value to return if the condition is false. |
Examples
| Expression | Result |
|---|---|
iif(1 == 1, 'condition met', 'condition not met') | condition met |
iif(1 == 2, 'condition met', 'condition not met') | condition not met |
📦 indexOf ​
Determines the index of the first occurrence of a specified string within a string (case-sensitive).
| Parameter | Type | Description |
|---|---|---|
| stringValue* | string | The string to search within. |
| lookupValue* | string | The string to search for. |
Examples
| Expression | Result |
|---|---|
indexOf('foobar', 'bar') | 3 |
📦 join ​
Concatenate elements of a collection into a single string, separated by a specified delimiter.
| Parameter | Type | Description |
|---|---|---|
| delimiter* | string | The character used to separate elements in a string. |
| list* | object[] | Collection of string values. |
Examples
| Expression | Result |
|---|---|
join('-', list('a', 'b', 'c') | a-b-c |
📦 lastOrDefault ​
Returns the last item in a list or null if the list is empty.
| Parameter | Type | Description |
|---|---|---|
| list* | object[] | The original list. |
Examples
| Expression | Result |
|---|---|
lastOrDefault(list(1, 2, 3)) | 3 |
lastOrDefault(list()) | NULL |
📦 length ​
Returns the length of a string.
| Parameter | Type | Description |
|---|---|---|
| input* | string | The string to get length. |
Examples
| Expression | Result |
|---|---|
length('text') | 4 |
length('') | 0 |
📦 list ​
Creates a list from the provided parameters, filtering out null values.
| Parameter | Type | Description |
|---|---|---|
| list* | object[] | The original list. |
Examples
| Expression | Result |
|---|---|
list(1, 2, 3) | [1, 2, 3] |
list(1, null, 3) | [1, 3] |
📦 list ​
Creates an empty list
| Parameter | Type | Description |
|---|
Examples
| Expression | Result |
|---|---|
list() | [] |
📦 localeValue ​
Returns the value of a LocaleValue for the specified locale or the default value if the locale is not found.
| Parameter | Type | Description |
|---|---|---|
| localeValue* | object | Translation object. |
| locale | string | The locale to get the value for. |
Examples
| Expression | Result |
|---|---|
localeValue([Name], "en-US") | Translation in English |
localeValue([Name]) | Default translation |
📦 multilang ​
Returns a LocaleValue object with the specified locale and value pairs. First value is the default value.
| Parameter | Type | Description |
|---|---|---|
| localesAndValues* | System.String[] | Locale and value pairs, where the first pair is the default value. |
Examples
| Expression | Result |
|---|---|
multilang('en-US', 'Hello', 'es-ES', 'Hola') | LocaleValue with English and Spanish translations |
multilang('en-US', 'Hello') | LocaleValue with English translation |
📦 objectCreate ​
Creates an object with the specified property name-value pairs. Parameters must be provided in pairs: property name, property value.
| Parameter | Type | Description |
|---|---|---|
| propertyPairs* | object[] | Property name-value pairs. Must be provided in alternating name, value sequence. |
Examples
| Expression | Result |
|---|---|
objectCreate('Name', 'John', 'Age', 30) | { Name: 'John', Age: 30 } |
objectCreate('Street', 'Main St', 'Number', '123') | { Street: 'Main St', Number: '123' } |
📦 orderBy ​
Orders a list by a lambda expression.
| Parameter | Type | Description |
|---|---|---|
| list* | object[] | The original list |
| predicate* | string | A string to represent the value to be evaluated |
| lambda* | string | The lambda expression |
| sortDirection | string | (Optional) The sort direction, either 'asc' or 'desc'. Defaults to 'asc'. |
Examples
| Expression | Result |
|---|---|
orderBy((3, 2, 1), 'x', 'x') | [1, 2, 3] |
orderBy((1, 2, 3), 'x', '-x') | [3, 2, 1] |
📦 parseInt ​
Parses a string to an integer. If the string cannot be parsed, returns the default value if provided.
| Parameter | Type | Description |
|---|---|---|
| input* | string | The string to parse. |
| defaultValue | int? | The default value to return if parsing fails. |
Examples
| Expression | Result |
|---|---|
parseInt('123') | 123 |
parseInt('abc', 0) | 0 |
📦 regexGroup ​
Extracts a named group from a string that matches a given regular expression pattern.
| Parameter | Type | Description |
|---|---|---|
| input* | string | The string to check. |
| pattern* | string | The regular expression pattern. |
| index* | int? | The index of the group to extract. |
Examples
| Expression | Result |
|---|---|
regexGroup('abc123', '^(?<prefix>[a-z]+)(?<number>[0-9]+)$', 0) | abc |
regexGroup('abc123', '^(?<prefix>[a-z]+)(?<number>[0-9]+)$', 1) | 123 |
regexGroup('abc123', '^(?<prefix>[a-z]+)(?<number>[0-9]+)$') | abc |
📦 regexIsMatch ​
Checks if a string matches a given regular expression pattern.
| Parameter | Type | Description |
|---|---|---|
| input* | string | The string to check. |
| pattern* | string | The regular expression pattern. |
Examples
| Expression | Result |
|---|---|
regexIsMatch('abc123', '^[a-z]+[0-9]+$') | true |
regexIsMatch('abc', '^[a-z]+[0-9]+$') | false |
📦 replace ​
Replaces all occurrences of a specified substring in a string with another substring.
| Parameter | Type | Description |
|---|---|---|
| value* | string | The original string. |
| oldValue* | string | The substring to be replaced. |
| newValue* | string | The substring to replace with. |
Examples
| Expression | Result |
|---|---|
replace('Hello World', 'World', 'Universe') | 'Hello Universe' |
📦 select ​
Selects items from a list based on a predicate and applies a lambda expression to each item.
| Parameter | Type | Description |
|---|---|---|
| list* | object[] | The original list. |
| predicate* | string | The predicate to evaluate for each item. |
| lambda* | string | The lambda expression to apply to each item. |
Examples
| Expression | Result |
|---|---|
select(list(1, 2, 3), 'x', 'x * 2') | [2, 4, 6] |
📦 skip ​
Skips a specified number of elements from the beginning of a collection and returns the remaining elements.
| Parameter | Type | Description |
|---|---|---|
| collection* | object[] | The collection to skip elements from. |
| count* | System.Int32 | The number of elements to skip. |
Examples
| Expression | Result |
|---|---|
skip([1, 2, 3, 4, 5], 2) | [3, 4, 5] |
skip([1, 2], 5) | [] |
📦 split ​
Divides a string into a list of substrings by specified separator.
| Parameter | Type | Description |
|---|---|---|
| input* | string | Input text to split |
| separator* | string | Separator |
Examples
| Expression | Result |
|---|---|
split('Jan,Feb,Mar,Apr', ',') | ['Jan', 'Feb', 'Mar', 'Apr'] |
📦 startsWith ​
Determines whether a string starts with a specified prefix (case-sensitive).
| Parameter | Type | Description |
|---|---|---|
| input* | string | The original string. |
| value* | string | The prefix to check for. |
Examples
| Expression | Result |
|---|---|
startsWith('Hello World', 'Hello') | true |
startsWith('Hello World', 'hello') | false |
📦 stringIsNullOrEmpty ​
Checks if a string is null or empty.
| Parameter | Type | Description |
|---|---|---|
| value* | string | a value to check if it is null or empty. |
Examples
| Expression | Result |
|---|---|
stringIsNullOrEmpty(' ') | true |
📦 substring ​
Extracts a substring from a string starting at the specified index with optional length.
| Parameter | Type | Description |
|---|---|---|
| input* | string | The original string. |
| startIndex* | System.Int32 | The starting index (0-based). |
| length | int? | The number of characters to extract (optional). |
Examples
| Expression | Result |
|---|---|
substring('Hello World', 0, 5) | 'Hello' |
substring('Hello World', 6) | 'World' |
📦 sum ​
Sums numeric items.
| Parameter | Type | Description |
|---|---|---|
| list* | object[] | The original list. |
Examples
| Expression | Result |
|---|---|
sum(list(1, 2, 3)) | 6 |
📦 take ​
Takes a specified number of elements from the beginning of a collection.
| Parameter | Type | Description |
|---|---|---|
| collection* | object[] | The collection to take elements from. |
| count* | System.Int32 | The number of elements to take. |
Examples
| Expression | Result |
|---|---|
take([1, 2, 3, 4, 5], 3) | [1, 2, 3] |
take([1, 2], 5) | [1, 2] |
📦 toLower ​
Converts a string to lowercase.
| Parameter | Type | Description |
|---|---|---|
| value* | string | The original list. |
Examples
| Expression | Result |
|---|---|
toLower('Hello World') | 'hello world' |
📦 toUpper ​
Converts a string to uppercase.
| Parameter | Type | Description |
|---|---|---|
| value* | string | The original list. |
Examples
| Expression | Result |
|---|---|
toUpper('Hello World') | 'HELLO WORLD' |
📦 trim ​
Removes leading and trailing whitespace from a string.
| Parameter | Type | Description |
|---|---|---|
| input* | string | The string to parse. |
Examples
| Expression | Result |
|---|---|
trim(' text ') | text |
📦 where ​
Filters a list based on a predicate and applies a lambda expression to each item.
| Parameter | Type | Description |
|---|---|---|
| list* | object[] | The original list. |
| predicate* | string | The predicate to evaluate for each item. |
| lambda* | string | The lambda expression to apply to each item. |
Examples
| Expression | Result |
|---|---|
where(list(1, 2, 3), 'x', 'x > 1') | [2, 3] |