| ILOG Rules for .NET User Guides > ILOG Rule Team Server for SharePoint > Structure of Business Rules > Conditions |
Conditions |
PREVIOUS NEXT |
The condition part of a rule specifies under what conditions the actions in the action part of the rule will be carried out. Conditions are represented by whatever appears after If, ending at Then (which signals the beginning of the action part of the rule).
For example, in the following rule, the call is redirected to a member of the Gold team only under the condition that the customer category is Gold:
If the customer category is Gold Then redirect the call to a member of the Gold team
This is a simple condition that is either true of false; the action is carried out if this condition is true.
The condition part of a rule can be made up of one or more condition statements. For example:
If the customer category is Gold
is a condition with one condition statement, whereas the following condition has two condition statements:
If all of the following conditions are true: the category of the customer is Gold the customer has been waiting longer than 5 minutes
When you have more than one condition statements, you can set whether the actions will be carried out if all or any of its rule statements are valid.
For example, the action will be performed when both of the following conditions are valid:
If all of the following conditions are true: the category of the customer is Gold a member of the Gold team is available Then redirect the call to a member of the Gold team
On the other hand, in the following rule the action is performed when either the customer's category is Gold or the customer has been waiting for longer than five minutes:
If any of the following conditions is true: the category of the customer is Gold the customer has been waiting longer than 5 minutes Then redirect the call to a member of the Gold team
How to do this using the features of the Rule Editor is explained in Editing Rules in the Rule Editor (section Control How Condition Statements are Combined).
The following entries in your drop-down lists help you construct your condition statements by testing for the occurrence of a given business term:
Used for writing conditions that test for the occurrence of something. For example, the following condition is met when there are 2 trucks available:
If there are 2 instances of a truck available
The optional where restriction can also be used. This example shows how to test if the number of Gold customers is equal to 10:
If
there are 10 instances of Customer
where the category of this Customer is Gold
Used for writing conditions that are satisfied when the number of occurrences of something:
This example shows how to test if the number of Gold customers is lower than or equal to 3:
If
there are at most 3 instances of Customer
where the category of this Customer is Gold
Another more advanced example first initializes the following variables:
The condition checks if the number of Gold customer is more than or equal to (Gold limit + 1).
Definitions
set Silver customers to all instances of Customer
where the category of this Customer is Silver
set Gold limit to the number of elements in Silver customers
If
there are at least Gold limit + 1 instances of Customer
where the category of this Customer is Gold
| Note |
| See Definitions for a description of how to use the Definitions part. |
Used for writing conditions that are satisfied when at least one occurrence of something exists.
This example illustrates how to test whether or not a Customer exists:
If
there is at least one instance of Customer
Another more advanced example shows how to test if a senior Gold customer exists:
Definitions
set Gold customers to all instances of Customer
where the category of this Customer is Gold
If
there is at least one instance of Customer in Gold customers
where the age of this Customer is at least 65
| Note |
| See Definitions for a description of how to use the Definitions part. |
You may want to write rules that are more easily expressed in terms of something not being true. For example, the following condition is met except when the customer category is Gold:
If the following condition is not true: the customer category is Gold
The following example illustrates how to test if a customer is not a Gold senior member.
If
the following condition is not true
any the following conditions are true
the category of the Customer is Gold
the age of the customer is least 65
How to negate condition statements using the features of the Rule Editor is explained in Editing Rules in the Rule Editor (section Negate a Condition Statement).
Operators let you compare or establish relationships between the different terms found in rule statements.
Different comparison operators are available to compare text, numbers, dates, and lists.
Text operators compare business terms that are of a textual nature:
Arithmetic operators compare numerical terms:
Date operators compare calendar dates:
Some business rules are made simpler through the use of variables. Variables let you identify and subsequently reference an occurrence of something by a convenient name.
Variables are useful when constructing rules that deal with relationships between two or more things of the same type. For example, the following condition statement involves two different customers:
If customer1 is married to customer2
Here, we have identified and named two different customers: customer1 and customer2. You can see that by making the notion of a customer something that varies, and having the possibility of identifying them specifically, you can create rules such as:
If all of the following conditions are true: customer1 is married to customer2 and customer2 is insured Then upgrade customer1's rating
| Note |
| Variables are defined in the Definitions part of the rule. |
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |