Step 1. Add a Rule to file iiiDepartments

REP007 - File Validation Rules/Triggers

In this step, you will review the field level validation rule defined on the iiiDeptCode field that you created in exercise REP001 - Create Fields.  (When you created the iiiDeptCode field, you copied the validation rules from the STD_CODE field.) You will also add a rule at file level to demonstrate how these rules interact.

1.  Open file iiiDepartments in the Editor.

2.  Select the Rules and triggers tab.

3.  Expand the two existing rules to see their complete details. Notice both rules are at field level and cannot be changed using the Details tab. (You need to open the field, to edit field level rules.)

     These rules state that the Department Code and the Department Description codes cannot be blank.

4.  Select the iiiDeptCode field in the list of rules to add a file level rule to it.

5.  Select Add button on the Home ribbon, and select an Add Range Check rule to the iiiDeptCode field.

6.  In the Details tab, create the rule as follows to ensure that the Department Code value has to be between A and ZZZ:


Dept must be A to ZZZ



When Inserting

Always apply rule (ADD)

When Updating

Apply when field is used (CHGUSE)

When Deleting

Never apply rule

From Value


To value



     Your Details tab should now look like this:

7.  In the Validation Usage section, create the rule actions to set the field in error if it is not in the allowed range:

If field is in the range of values

Evaluate next rule (NEXT)

If field is NOT in range of values

Set field in error (ERROR)

Message Number

(delete the entry in this field)

Message File

(delete the entry in this field)

Message Text

Dept must be in range A to ZZZ


     Your Details tab should now look like this:

     The recommended way to specify the message text is to use a message defined in a Message file as shown in Step 3. Create a Rule for the iiiSalary Field. However, for simplicity in the rest of this exercise, you will enter the message text in the rule definition.

8.  Save the file.