Conditions that test for a number
You can build conditions that check whether one or more objects exist in a set of data.
The following definitions cover operators that test for specified data.
- there are
The operator there are tests whether there is a specific number of objects of a certain type in the data from the application that calls the rule.
The following condition checks for two flights:
if there are 2 flights in the flights of 'the customer' then...
You can use the operator where to specify more conditions to apply to business terms.
The following rule condition is only true if there are 10 customers, and if each customer is a member of the Gold category:
if there are 10 customers where the category of each customer is Gold, then...
You can also use time filter operators to check that a collection of objects exists at a time related to a specific time period or time point. In a condition with the operator where, the time filter operator comes first.
Use the following operators to filter a collection of objects according to a time period:- before
- after
- during
Use the following operators to filter a collection of objects according to a time point:- before
- after
- at
- before or at
- at or after
For example, use the during operator with a time window to apply a filtering to the business terms according to this time window. The following rule condition checks for two flights in the last two weeks where the customer is a member of the Gold category:
if there are 2 flights in the flights of 'the customer' during the last period of 2 weeks where the category of 'the customer' is Gold, then...
- there are at least and there are at most
The following operators check whether data contains more or fewer instances of a business term than a specified number:
there are at least: The condition is true if the number of occurrences of the business term is greater than or equal to the specified number.
there are at most: The condition is true if the number of occurrences of the business term is less than or equal to the specified number.
The following condition checks that there are no more than three Gold customers:
if there are at most 3 customers where the category of each customer is Gold, then...
The following condition checks whether there are more Gold customers than Silver customers. The rule starts by defining the following variables:
silver customers: The list of customers in the Silver category.
silver count: The number of customers in the Silver category.
The rule then uses these variables to compare the number of Gold customers with the number of Silver customers:
definitions set 'silver customers' to all customers in the boarded passengers of 'the flight' where the category of each customer is Silver; set 'silver count' to the number of 'silver customers' if there are at least ('silver count' + 1) customers where the category of each customer is Gold, then...
- there is at least one
The operator there is at least one checks that there is at least one instance of a business term in the data from the application that calls the rule. The data can contain more than one instance of the business term.
The following condition looks for at least one customer object:
if there is at least one customer then...
The following example checks for at least one senior Gold customer:
definitions set 'gold customers' to all customers in the boarded passengers of 'the flight' where the category of each customer is Gold; if there is at least one customer in 'gold customers' where the age of this customer is at least 65, then...