ILOG Rules for .NET User Guides > ILOG Rule Team Server for SharePoint > Working with Rules

This section describes how to create, delete, and edit your rules or decision tables in Rule Team Server.

Note
Reference information on the structure of business rules and decision tables is provided in Structure of Business Rules and Structure of Decision Tables.

Create a Rule

You may want to create a new rule inside an exsiting RuleDoc.

Note
It is not possible to create a new decision table. This is done in ILOG Rule Studio for .NET.

To create a new rule:
  1. Check out the RuleDoc (see Check Out and Check In).
  2. Click New Rule in the RuleDoc Browser.
    Note
    You must have the RuleDoc checked out to have the toolbar available.
  3. Type in the name of the new rule as well as its package (see Rule Properties), and click OK.
    Note
    The best practice is to place all the rules belonging to a package inside a RuleDoc bearing the same name.
  4. The rule is added to the end of the RuleDoc.
  5. Select your new rule in the RuleDoc Browser.
  6. Construct your rule in the Rule Editor as described in sections Editing Rules in the Rule Editor and Editing Rules in Decision Tables.
  7. Modify any properties that you want to change in the Rule Property Editor (see Rule Properties).
  8. Check in the RuleDoc (see Check Out and Check In).

Delete a Rule

You may want to delete a rule or decision table from your RuleDoc.

Note that deleting all the rules in a RuleDoc will not delete the RuleDoc itself, as it still may contain text, images, or objects that you may want to keep. Also, you may want to keep an empty RuleDoc to preserve its history under SharePoint.

Note
Deleting a RuleDoc is explained in Delete a RuleDoc or Rule Document Library.

To delete a rule or decision table from an existing RuleDoc:
  1. Check out the RuleDoc (see Check Out and Check In).
  2. Select the rule or decision table to delete in the RuleDoc Browser by clicking the option button beside its name.
    Note
    The RuleDoc Browser displays its entries by groups of 10 at one time. If your RuleDoc contains more than 10 entries you can click on the numbers at the bottom of the RuleDoc Browser to access other pages of rules or decision tables.
  3. Click Delete Rule in the RuleDoc Browser toolbar, and then click OK to confirm.
    Note
    You must have the RuleDoc checked out to have the toolbar available.
  4. Check in the RuleDoc (see Check Out and Check In).

Editing Rules in the Rule Editor

The Rule Editor lets you edit your business rules.

The rule statements that make up a rule appear as complete phrases because they use a natural-language approach, but when constructing or editing them you see that they are made up of combinations of modifiable building blocks, which represent business terms, operators, and values. For example, in the following rule statement:

 If
     the current load is more than 5000

the building block the current load is a business term, is more than is an arithmetic operator, and 5000 is a value.

In the Rule Editor you construct rules from the predefined building blocks by entering text or numbers in fields, or by selecting terms in lists. Note that you can filter the choices available in the list by starting to type a word or phrase.

Furthermore, a business term may be part of a longer phrase. For example, selecting an item such as the following in your drop-down list

 the age of <the customer>

will require you to subsequently complete the business term <the customer> in that phrase.

More information on the structure of your rules can be found in Structure of Business Rules and Structure of Decision Tables.

Note
You must have the RuleDoc checked out to edit rules in the Rule Editor.

Add or Remove Rule Statements

You can add or remove rule statements in order to refine your rules.

At least one action must be specified in the action part of a business rule. Consequently, you will not be able to delete the last action of a rule.

Control How Condition Statements are Combined

When the condition part of a rule contains more than one statement, you can control whether the condition part of the rule is met if all or any of its rule statements are valid.

To change how condition statements are combined:
  1. Click directly on the all of the following conditions are true or any of the following conditions are true operators.
  2. Choose the correct one.

For more information on how these operators are interpreted, see Combine Condition Statements.

Negate a Condition Statement

You can negate a condition statement by adding the following condition is not true at the beginning of the statement. (More information on this is available in section Negate Condition Statements.)

To negate a condition statement:
  1. Click the condition statement.
  2. Click the following condition is not true in the drop-down list.

Open an Empty Part of a Rule

If the title of a part of a rule appears in italics, this means that it is currently empty.

To open an empty part of a rule:
  1. Click the title.
  2. Insert a statement in that part.

Entering Values in Fields

You may want to enter a value in a field instead of selecting it from a drop-down list.

To change to a field:
  1. Click the business term and select Values from the drop-down list (date, number, string).
  2. Once selected, a pencil icon appears to the right of the drop-down list.
  3. Click the pencil icon to display a field.
  4. Type in the text and press ENTER.

Use Lists of Categories

In large business rule applications, it is possible to reduce the number of terms that appear in your drop-down lists by the use of categories.

If your application has been setup to use categories, the Rule Editor will display the Category combo box.

Select a term in the combo box to only display in your drop-down lists terms from that category.

Selecting All means that the terms from all the categories will be displayed in your drop-down lists.

Handle Error Messages

The Rule Editor will underline in red any terms that are not correct.

To remove these error messages, simply correct the term, for example by typing-in a number rather than typing-in text.

Note
The Rule Editor will let you save incorrect values, contrary to the Rule Property Editor, which will only save correct properties.

Use the Variables Defined by the Rule Editor

Business rules are often made simpler through the use of variables, which let you identify and subsequently reference an occurrence of something by a convenient name. This is explained in Definitions.

The Rule Editor defines one variable for each type of business term that it encounters, and identifies it with the word "the". For example, if customer is something you work with in your rules, the Rule Editor will define a variable called the customer which you can use.

If your rule requires you to refer to more than one occurrence of a customer, you have to explicitly define the other variables in the Definitions part.

Editing Rules in Decision Tables

The Decision Table Editor displays the rows and columns of your decision tables, and provides features that let you edit your rules.

It is made up of a table part, as well as a toolbar at the top that lets you access to features that either enhance readability or give you more information on your decision tables:

images/tms_dtable_editor.png

Preconditions, rule information, and messages are displayed just below the decision table. When you access these features, the icon disappears from the toolbar until you close the feature (by clicking the X at the top right of its display area).

Displaying rule or column information

Use the rule information icon images/tms_dtable_icon_showrule.png or click directly on a row number to display the rule at the bottom of the editor in its usual If-Then form.

Similarly, placing your cursor over a column header will display in the tooltip the entire condition or action.

Expand or contract groups of rows

To make your decision tables easier to read, you can expand or contract groups of rows (see Partitioned Cells) by clicking the + or - signs at the right of partitioned cells.

Sort columns

You can sort some columns in ascending or descending order by using the up and down arrows at the right of the column header (sorting is done within the partition for groups of related cells (see Partitioned Cells)).

Enable paging mode

Use the paging mode icon images/tms_dtable_icon_paging.png if you want to only display a certain amount of rows at a given time rather than the entire table.

Once paging mode is enabled, you use the scrollbar at the right of the decision table to access the other pages of rules.

Click on the paging mode icon again to disable paging mode.

Add a Row

You can add rows to decision tables to create new rules (you must have the RuleDoc checked out to do so).

To add a row:
  1. Identify the row over or under which you wish to add the new row.
  2. In this row, click on the down arrow at the right of the cell.
  3. If you choose the down arrow in a cell that has columns to the left of it, the new row will be created sharing the same value for the cells to its left. This is explained in more detail in Rows and Cells.
  4. Select from the contextual menu where to add the row:
  5. Fill in the cells of the new row.
  6. Check the RuleDoc back in.

Delete a Row

You can delete rows from decision tables (you must have the RuleDoc checked out to do so).

To delete a row:
  1. Click on the down arrow at the right of the appropriate cell in the row you want to delete.
  2. If you choose the down arrow in a cell that has partitioned cells to the right of it, all the rows that share the cell will be deleted. This is explained in more detail in Rows and Cells.
  3. Select Delete row in the contextual menu.
  4. Check the RuleDoc back in.

Edit a Cell

Cells are edited by either typing in values, selecting predefined values from a drop-down list, or by changing the operator that acts on a given cell.

To edit a cell:
  1. Make sure your RuleDoc is checked out (see Check Out and Check In).
  2. Click directly in the cell that you want to edit.
  3. If the cell contains a drop-down list, choose the correct entry in the list.
  4. If the cell contains a text or number field, type in the new value in the field displayed, and then press ENTER.
    Warning
    You must press ENTER with your cursor placed in the field for the changes to be captured. Otherwise you will not be able to do anything else in the Rule Editor.
  5. You can change the operator that acts on a given cell by clicking on the cell and then selecting the new operator in the Change local operator drop-down list located just below the table.
  6. A description of the available operators is provided in section Conditions.
  7. Check the RuleDoc back in.

Decision Table Errors

Rule Team Server advises you of errors in your decision table by:

Errors caused by incomplete or invalid expressions in your decision tables are signaled by a red mark, whereas errors caused by overlapping entries or entries with gaps are signaled by a blue mark. These are described as follows:

Note
Although you can save incorrect values, the rules will not successfully deploy to the end-user applications if they contain invalid expressions.

Expression Errors

Rule Team Server verifies that the values you enter in the cells of a decision table match the type of value the column expects, and that the number of arguments is correct.

For example, you get an error when you do not provide both the maximum and minimum values for a range of numbers, or if you enter text when you should enter a number.

Overlap Errors

Rule Team Server verifies that the values you enter for a given condition throughout the different rows do not overlap or are not identical.

Consider for example a column for the age of the customer:

In this example, customers that are 29 years old will satisfy the condition of both rows; this is signaled as an overlap error.

Overlap errors are evaluated for all the entries in a given column, or within partitioned groups of cells (see Partitioned Cells).

Gap Errors

Rule Team Server verifies that the cells in a condition column consider all possible cases. This ensures that there are no gaps in your tables.

Consider for example a column for the age of the customer:

In this example, customers that are 31 years old will never be taken into account; this is signaled as a gap error.

Gap errors are evaluated for all the entries in a given column, or within partitioned groups of cells (see Partitioned Cells).

Disabling an Action Cell

It is possible to disable any action cells so that the action is not carried out for that particular row. This is equivalent to clearing the contents of the cell, except that you keep the information it contains in view of re-enabling it.

To disable an action cell:
  1. Click in the cell you want to disable.
  2. In the Enabled field located just below the table, select False in the drop-down list to indicate that this cell will no longer be enabled.
  3. Once the cell is disabled, a red cross will be displayed in that cell.
  4. To re-enable the cell, set the Enabled field back to True.

Displaying Ruleflow

Ruleflows define the "flow" of execution of business rules and decision tables in a rule project in terms of three kinds of tasks--rule, action and flow--and the transitions between them.

Ruleflows are contained in RuleDocs and you can consult them in the Rule Editor:

images/tms_editor_ruleflow.png

Note that you cannot edit ruleflows in Rule Team Server. This is done in ILOG Rule Studio for .NET. You can, however, edit their properties in the Rule Property Editor (see Rule Properties).

Ruleflows are composed of the following parts:

Start Points and End Points

Every ruleflow has one start point and at least one end point. Start and end points are graphical markers for the start and end of a ruleflow. They do not have any functional properties.

Tasks begin executing after a ruleflow's start point, and stop executing when an end point is reached.

Tasks

A ruleflow consists of linked tasks. The tasks of a ruleflow contain the instructions for which rules to execute and in what order. Some tasks (rule tasks) contain a list of business rules and decision tables to execute. You can also have tasks that just perform actions (action tasks), and some that contain other ruleflows (flow tasks).

Rule task 
images/rf_ruletask.png  
A rule task is a task that references and orders business rules and decision tables. When a rule task is performed the referenced rules and tables are executed in the specified order. 
Action task 
images/rf_actiontask.png  
An action task contains actions. The actions of an action task are defined in the same way as the actions for business rules. 
Flow task 
images/rf_flowtask.png  
A flow task is a task that references another ruleflow. The referenced ruleflow can be the current ruleflow or any other ruleflow within the rule project. 

Initial and Final Actions

One or more actions can be attached to a task. Initial actions are applied before a task is performed, and final actions are applied after a task is performed. Initial and final actions are defined in the same way as actions for an action task.

Transitions and Transition Conditions

Transitions connect tasks in a ruleflow and define the "flow" of the ruleflow from one task to another. Transitions are unidirectional, and conditions can be attached to them.

Transition conditions provide a mechanism to control the ruleflow from task to task. Transition conditions are defined the same way as conditions in a business rule. For example, with the following condition on the transition between the Eligibility and Pricing rule tasks, the Pricing rules can only be performed when the customer is eligible, otherwise the Other Offers rule task is executed.

images/rf_else.png

"Else" Paths

When a condition is added to a transition, a path with no condition must always be provided to act as the "else" path, that is, the path to take when the condition is not true must be specified.

There can be many transitions after a task. However, only one of them can be an "else" path, that is, all the transitions except the else path must have conditions. For example, in the following there are three transitions after the Eligibility rule task. If the eligibility cannot be determined using the existing information the More Information rule task is executed. If the customer is definitely eligible, the Pricing rule task is executed. An else path is provided to the Other Offers rule task for the case in which the customer is definitely not eligible.

images/rf_many_transitions.png