Condition
Function -> Condition(param 1, param 2, param 3, param 4) ? returnValue1 : returnValue 2
"Condition" function can be used to compare two values or attributes. This function can be used on global and asset class specific attributes.
param 1 - This parameter can be a fixed value or derived from a Formula.
param 2 - This parameter can be a fixed value or derived from a Formula. This value can also be null
param 3 - condition operator
- eq
- lt
- le
- gt
- ge
- ne
param 4(Optional) - when the function is run. Options -
- CREATE - Function will be run only when an asset is created
- UPDATE - Function will be run when an asset is created or modified
This function is run automatically in the background whenever an asset is created or updated via import, web interface or mobile app.
When run inside a "value" function, param 4 is not required.
Below condition function will evaluate to false whenever an asset with attribute BEACON is created or updated and its value is empty, blank or missing
Condition([$attribute.BEACON], null, ne, UPDATE)
When used as a post processing function on its own, the create or update of an asset will fail when condition evaluates to false. Update or create asset will succeed, if condition evaluates to true.
Ternary Operator(Optional):
We can specify ternary operator with the Condition Function in same string with true_case and false_case values. This is generally used with the value function. If condition is evaluated as true then true_case value will be applied, and when evaluated false, false_case value will be applied. False case can be provided null if update should not happen when condition evaluated to false.
Condition([$attribute.Head], True, eq) ? [$sequence]: null
Condition(4, 5, le) ? xyz:123
Updated 27 days ago