Rule builder

Rule builder

The rule builder is the shared condition editor used across 3B Onboarding. The same rule JSON and the same evaluation engine power:

A rule is always evaluated against one Contact. It is made of condition groups, each holding conditions, each holding condition items. Groups and items are combined with All, Any or a custom boolean expression such as (1 AND 2) OR 3.

Anatomy of a rule

Level What it is Combined with
Group A block of conditions Cross group operator (All groups, Any group, Custom)
Condition A target object: the Contact itself or one child object related to it, plus a match mode Cross condition operator inside the group
Condition item One field comparison or function on the target object Cross item operator inside the condition

The target object list contains the Contact and every child object that has a lookup or master-detail to Contact. When the target object is a child object, the engine loads every related record of that object (up to 500, ordered by created date) and evaluates the items against them.

Fields on the target object can be relationship paths. Select a lookup field, then use the drill-down button to pick a field on the parent record, for example the Job name on an Application.

Match mode

Every condition on a child object has a match mode that decides which of the related records must satisfy the condition items. Records are ordered by created date, oldest first.

Match mode Passes when No related records
Any record matches (default) At least one record satisfies the items Fails
All records match Every record satisfies the items Fails
No record matches No record satisfies the items Passes
First record matches The oldest record satisfies the items Fails
Last record matches The newest record satisfies the items Fails
At least N records match N or more records satisfy the items Fails

Existing rules saved before match modes existed keep working unchanged. A missing match mode means Any. The match mode is hidden when the target object is the Contact because there is only one record.

Typical uses:

Comparators

The comparator list depends on the selected field type.

Comparator Field types Notes
Equals, Not Equals All Text comparisons ignore case
Contains, Not Contains, Starts With, Ends With Text, picklist, email, phone, URL
Greater Than, Less Than, More or Equal, Less or Equal Number, currency, percent, date, datetime, time
Is Blank, Is Not Blank All except checkbox No target value is required
In List, Not In List Text, picklist, lookup Comma separated values, or pick many values for a picklist
Includes Any Of, Excludes All Of Multi-select picklist Includes passes when the record has at least one of the chosen values. Excludes passes when it has none

Relative dates

Date and datetime target values can be a relative token instead of a fixed date. The comparator applies to the range the token represents: Equals means inside the range, Greater Than means after it, Less Than means before it.

Token Meaning
Today, Yesterday, Tomorrow That single day
This week, Last week, Next week Monday to Sunday
This month, Last month, Next month Calendar month
This year, Last year, Next year Calendar year
Last N days Today and the N days before it
Next N days The N days after today
Today plus N days The single day N days from today
Today minus N days The single day N days ago

Example, "expires within 30 days": Certificate, Any record matches, End Date less or equal Today plus 30 days.

Today plus and Today minus are available in the rule builder only. Compliance evidence conditions are translated to database queries and do not offer them.

For Last N days, Next N days, Today plus N days and Today minus N days, enter a whole number of at least 1 in the Days field. The selected relative mode remains active while the Days value is entered or corrected.

Functions

When the target object is a child object, the field list starts with functions that work over every related record of that object, regardless of the match mode and of the other items in the condition.

Function Field types Result
count() Number of related records
sum(field) Number, currency, percent Total of the field, blanks ignored
min(field) Number, currency, percent, date, datetime Smallest value, blanks ignored
max(field) Number, currency, percent, date, datetime Largest value, blanks ignored

Date functions accept relative date tokens as the target value. A function over records that have no value in the field never passes.

Example, "the most recent end date is still in the future": Certificate, max(End Date) greater than Today.

To count only records that satisfy other criteria, use the At least N match mode with the criteria as condition items instead of count().

Testing a rule

Pick a Contact at the top of the builder and click Evaluate. The engine runs the rule for that Contact and the builder shows:

The value shown is taken from the last evaluated record. For Any, First and Last it is the matching record. For All it is the first record that failed. For functions it is the computed result.

Rule JSON reference

Rules are stored as JSON. Integrators building rules programmatically, for example through the API or data loads, can use the following shape.

{
  "crossGroupOperator": "and",
  "customCrossGroupOperator": null,
  "groups": [
    {
      "uuid": "g1",
      "crossConditionOperator": "and",
      "customCrossConditionOperator": null,
      "conditions": [
        {
          "uuid": "c1",
          "targetObject": "b3o__Certificate__c*b3o__Contact__c",
          "matchMode": "last",
          "matchCount": null,
          "crossConditionItemOperator": "and",
          "customCrossConditionItemOperator": null,
          "conditionItems": [
            {
              "uuid": "i1",
              "targetObjectField": "b3o__Category__c*STRING",
              "targetValueComparitor": "equals",
              "targetObjectFieldValue": "DBS"
            },
            {
              "uuid": "i2",
              "targetObjectField": "b3o__End_Date__c*DATE",
              "targetValueComparitor": "more-or-equal",
              "targetObjectFieldValue": "$TODAY+30"
            }
          ]
        }
      ]
    }
  ]
}
Key Values
targetObject Contact or <ChildObject>*<LookupFieldToContact>
matchMode any (or omitted), all, none, first, last, at-least
matchCount Integer, used with at-least
targetObjectField <field or path>*<FIELD TYPE>, or a function: custom_count*INTEGER, custom_sum:<field>*<TYPE>, custom_min:<field>*<TYPE>, custom_max:<field>*<TYPE>
targetValueComparitor equals, not-equals, contains, not-contains, starts-with, ends-with, more-than, less-than, more-or-equal, less-or-equal, is-blank, is-not-blank, in-list, not-in-list, includes, excludes
targetObjectFieldValue The value. Comma separated for in-list, semicolon separated for includes and excludes, a relative token such as $TODAY, $NEXT_N_DAYS:7 or $TODAY-90 for dates

Operators such as crossGroupOperator take and, or or custom. With custom, the matching custom...Operator key holds an expression over 1-based positions, for example (1 AND 2) OR 3.

Performance notes

Each condition on a child object costs one query, run once per rule evaluation even when several conditions use the same object. Everything else, including match modes, functions and list comparators, is evaluated in memory. Avoid rules on high-volume child objects such as shifts or availability, because only the first 500 related records are loaded.