Skip to main content

Define conditions with the condition builder

Zuora

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:

ui_elements.png

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:
  • Is equal to
  • Is not equal to
  • Is greater than
  • Is greater than or equal to
  • Is less than
  • Is less than or equal to
  • Starts with
  • In or match
  • Is null
  • Is not null
  • Is empty
  • Is not empty

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:
  • AND
  • OR

Basic concepts

Condition and group are basic components in the condition builder:

condition_structure.png

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

  1. ConA AND ConB → Result
  2. Result OR ConC 

ConA AND (ConB OR ConC)

ConB and ConC are grouped.

  1. ConB OR ConC → Result
  2. ConA AND Result

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:

  1. Click + Add Condition to create a condition.
  2. 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.
  3. Repeat steps 1 and 2 to create as many conditions as you need.
  4. If you have created more than one condition, select a logical operator from the dropdown list.
  5. 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 trash_can.png 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

example_and_operator.png

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

example_multiple_change_types.png
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

example_custom_object.png

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

example_groups.png

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

example_subgroup.png

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