Define conditions with the condition builder
The condition builder, a complement to the Java-Expression-Language-based (JEXL-based) approach for defining conditions, enables you to define conditions for custom events or custom scheduled events in the Zuora UI in an intuitive and visualized way.
This article describes the UI elements of the condition builder, basic concepts, and how to define conditions with the condition builder, and provides examples for various use cases.
UI elements
You can define conditions with the condition builder when configuring custom events and custom scheduled events in the Zuora UI. For more information, see Manage custom events and custom scheduled events.
The following figure shows the user interface of the condition builder:
You can find the details of each numbered element in the following table:
Element number | Description | Note |
---|---|---|
1 | The button for adding conditions. | The group-level Add Condition button allows you to add a condition to that specific group. |
2 | The button for adding groups. | The group-level Add Group button allows you to add a sub-group to that specific group. |
3 | The field component of a condition. | |
4 | The comparison operator component of a condition. | Available values are as follows:
For more complex operators, switch to Advanced (JEXL) mode. For more information, see Manage custom events and custom scheduled events. |
5 | The value component of a condition. | |
6 | The Static toggle that controls the value type. | |
7 | The button for deleting conditions. | |
8 | The logical operator that connects conditions and groups. | Available values are as follows:
|
Basic concepts
Condition and group are basic components in the condition builder:
Condition
A condition consists of three fields: Field, Operator (comparison operator), and Value. For example:
- Field: Amount
- Operator: is greater than
- Value: 1000.0
Each custom event or custom scheduled event can contain multiple conditions, which must be connected by logical operators (AND or OR).
Operator precedence and group
The evaluation order of conditions is based on operator precedence. The AND operator has higher precedence than the OR operator. To customize the order, you can use groups, which have the highest precedence.
The following is an example:
Conditions | Evaluation order |
---|---|
ConA AND ConB OR ConC |
|
ConA AND (ConB OR ConC) ConB and ConC are grouped. |
|
Add conditions and groups
You can use the condition builder to define conditions when creating a custom event or custom scheduled event in the Zuora UI. For more information, see Manage custom events and custom scheduled events.
To define conditions with the condition builder, take the following steps:
- Click + Add Condition to create a condition.
- Specify the following fields for the condition:
- Select a value from the Field list. Available values are as follows:
- Change Type: Indicates the base object change type. Available values are INSERT, UPDATE, and DELETE.
- Field name: Indicates the value of a base object field. For example, Amount or CreatedDate.
- Field name (Old): Indicates the value of a base object field before the change occurred. For example, Amount (Old) or CreatedDate (Old).
- Select a comparison operator from the Operator list. For more information, see Available comparison operators.
- Specify a value for the Value field:
- If you want to specify a static value, such as a number or string, switch on the Static toggle.
- If you want to specify a base object field, switch off the Static toggle.
- Select a value from the Field list. Available values are as follows:
- Repeat steps 1 and 2 to create as many conditions as you need.
- If you have created more than one condition, select a logical operator from the dropdown list.
- Optional: Click + Add Group to create a group, and then repeat steps 1 to 4 to create conditions for the group.
Delete conditions and groups
To delete a condition, click the trash can icon to the right of the condition.
To delete a group, you must delete every condition in the group. When you have deleted the last condition, the group will be deleted automatically.
Available comparison operators
In a condition, the comparison operator checks the values in the Field and Value fields and returns a boolean value.
The following table lists all supported comparison operators and examples:
Operator | Example of the Field field | Example of the Value field |
---|---|---|
Is equal to | Change Type | UPDATE |
Is not equal to | Change Type | DELETE |
Is greater than | (Invoice) Amount | 1000.0 |
Is greater than or equal to | (Invoice) Amount | 1000.0 |
Is less than | (Invoice) Amount | 1000.0 |
Is less than or equal to | (Invoice) Amount | 1000.0 |
Starts with | (Account) AccountNumber | A |
In or match | (Account) Batch | Batch8, Batch9 |
Is null | (Account) CrmId | (N/A) |
Is not null | (Account) CrmId | (N/A) |
Is empty | (Account) Notes | (N/A) |
Is not empty | (Account) Notes | (N/A) |
Examples of conditions for common use cases
Conditions with the AND operator
The conditions defined in the figure are equal to the following JEXL expression:
changeType == 'UPDATE' && Invoice.Status == 'Posted' && Invoice.Status_old != 'Posted' && Invoice.Amount > 1000.0
It is triggered when an invoice is posted with an amount greater than 1000.
Conditions for multiple change types
The conditions defined in the figure are equal to the following JEXL expression:
changeType == 'INSERT' || changeType == 'UPDATE'
It is triggered when a record of the base object is created or updated.
Conditions for custom objects
The conditions defined in the figure are equal to the following JEXL expression:
changeType == 'UPDATE' && default__entitlement.Usage__c >= default__entitlement.Entitled__c && default__entitlement.Status != 'Trial'
It is triggered when an entitlement record is updated if the usage equals to or greater than the entitlement and the entitlement status is not trial.
Conditions and groups
The conditions defined in the figure are equal to the following JEXL expression:
changeType == 'UPDATE' && (Invoice.Status == 'Draft' || Invoice.Status == 'Posted') && (Invoice.Amount < 20.0 || Invoice.Amount > 1000.0)
It is triggered when an invoice of Draft or Posted status is updated with an amount less than 20 or greater than 1000.
Groups and sub-groups
The conditions defined in the figure are equal to the following JEXL expression:
changeType == 'UPDATE' && (default__entitlements.Status__c == 'Trial' || (default__entitlements.Usage__c < default__entitlements.Entitled__c && default__entitlements.Usage__c > 10.0))
It is triggered when an entitlement record is updated and the entitlement status is trial, or the usage is less than the entitled value and greater than 10.
Notes and limitations
- You can use only one logical operator type (AND or OR) to connect the conditions in a specific group.
Use a sub-group to combine the AND and OR operators in a group. For example,ConA AND (ConB OR (ConC AND ConD))
. - The Value field is not available if the operator is one of the following:
- Is null
- Is not null
- Is empty
- Is not empty