Definition Conditionality: Difference between revisions
(Created page with "Within the app definition, you can create conditional statements and matchers that can return data or evaluate boolean conditions to determine the outcome. == Matchers == A matcher is an object definition that instructs the system to match a field value to another field, to a custom literal or to evaluate a conditional. The matcher always returns a value - this is the value that will be used by the schema. The example below is a matcher created with a conditional. The...") |
(No difference)
|
Revision as of 23:51, 4 December 2024
Within the app definition, you can create conditional statements and matchers that can return data or evaluate boolean conditions to determine the outcome.
Matchers
A matcher is an object definition that instructs the system to match a field value to another field, to a custom literal or to evaluate a conditional. The matcher always returns a value - this is the value that will be used by the schema.
The example below is a matcher created with a conditional. The conditional checks if the Field Day_Type__c (which is a picklist with Morning and Afternoon options) matches any value and if it does, it converts the select type to a string literal - i.e. Morning becomes AM and Afternoon becomes PM. In addition to the "literal" return type, you can also define a "targetField" return type - this will return the value of the field path defined.
//Example 1
"match": {
"field": "Day_Type__c",
"equals": {
"Morning": {
"literal": "AM"
},
"Afternoon": {
"literal": "PM"
},
},
"otherwise": {
"literal": null
}
}
//Example 2
"match": {
"field": "Day_Type__c",
"formatter": "date",
"equals": {
"Morning": {
"targetField": "Start_Date__c"
},
"Afternoon": {
"targetField": "Placement__r.Start_Date__c"
}
},
"otherwise": {
"literal": null
}
}
The example below is a matcher created to return the value of a specific field path.
"match": {
"field": "b3s__Contact__r.Name"
}
The fingerprint for a matcher is as follows
- field - this is the record field to evaluate
- formatter - optional addition - you can specify the following formatters: Date, Time, Date Time
- evaluation (equals) - this is the evaluation operator - defaulted to "equals"
- otherwise - optional "then that" block. Will be executed when neither of the values were matched in the "equals" object.
Selectors
Selectors are if-this-then-that conditional objects that control the flow of the operations. In some instances, a group of selectors can be added, but generally, a single selector has the following footprint:
- field - the field is the field path, the value of which will be used for the comparison
- operator - the operator can be 'equals', 'isnull', 'notequals' and 'in' ("in" checks if the field value is in the selector value)
- value/ targetField - value is the static value for comparison - a string, boolean or array; targetField is the dynamic value for comparison (i.e. check against another field)
//Example 1
{
"field": "Day_Type__c", //Schedulable object field
"operator": "equals", //Operator
"value": "Morning" //A literal value
}
//Example 2
{
"field": "Day_Type__c",
"operator": "equals",
"targetField": "Request__r.Day_Type__c" //Matching another field on the same object record
}
You can also assign multiple selectors like so:
//Example 1
{
"required": "condition": {
"allOrSome": "all", //all or some
"selectors": [
{
"field": "Id",
"operator": "isnull",
"value": false,
},
],
},
}
//Example 2
"condition": {
"allOrSome": "all",
"selectors": [
{
"field": "Day_Type__c",
"operator": "in",
"value": ["Morning", "Evening"]
},
{
"field": "Cancelled__c",
"operator": "equals",
"value": true
},
{
"field": "Contact__c",
"operator": "isnull",
"value": false
}
]
}
Multiple selectors can be chained via a conditional object (also called conditional). The conditional object has two properties: allOrSome (which accepts the values all or some) and an array of selectors. the allOrSome attribute controls how the selectors are executed. Here's the footprint for defining a multi-selector conditional:
- allOrSome - all will equivalate to "AND" conditional and some will equivalate to "OR" conditional across the array of selectors.
- selectors - an array of selectors
The "operator" can be set to:
- 'equals' checks for equality
- 'isnull' - checks if the value is null
- 'notequals' - checks of inequality
- 'in' - checks if the value is in a given array