How to Add a Quick Rule to a Table

This step shows how to add Quick Rules to a table definition.

When you define a business rules for a table column, the rules apply to the column in this table. The field on which the column is based can have different rules or no rule when it defines a column in another table.

Quick Rules speed up your rule setting by requiring just one click to apply the rule to a column. The Quick Rules available for a column depend on the type of the column.

See Quick Rules for Tables in the Technical Reference Guide for further details.

1.     Select the Rules and Triggers tab for table MyEmployee. Select the xEmployeeSurname column.

2.     On the Home ribbon, from the Add menu, select Quick Rules -> Cannot be empty:

 3.    A Simple Logic Check is defined and shown on the Details tab:

4.     Check the Validation Usage settings to make sure they are suitable. The default values "Always apply rule ……" means the rule will be applied every time the table is updated or a new record is inserted whether or not the application code included this column in the update. Consider this statement for example, where Surname is not being updated:

 

Update Fields(#xEmployeeSalary) in_file(MyEmployee) With_Key(#xEmployeeIndentification)

        If column xEmployeeSurname in the table is currently blank, the rule "Always apply rule (CHG)" would produce an error for column Surname.

        The value "Apply when column is used (CHGUSE)" means the rule applies only if Surname is included in the update. For example, the following would produce an error if Surname is blank:

 

Update Fields(#xEmployeeSurname #xEmployeeGivenNames) in_file(MyEmployee) With_Key(#xEmployeeIndentification)

       The following code will not produce an error if column Surname in the record is currently blank because column xEmployeeSurname is not included in the Fields() parameter.

 

Update Fields(#xEmployeeSalary) in_file(MyEmployee) With_Key(#xEmployeeIndentification)

        For your own applications, change the When inserting, When updating rules if necessary.

5.     Now you will add Quick Rule, Before today for a date type field.

         Select the column xEmployeeDateofBirth on the Rules and Triggers tab. From the Add menu / Quick Rules select Before today. A Simple Logic Check will be defined with details shown on the Details tab and the Rules and Triggers tab:

6.     Review the Validation Usage and change if necessary.

7.     Next add Quick Rule,  Cannot be zero for a numeric column.

        Select the column xEmployeeSalary on the Rules and Triggers tab. From the Add menu, select Quick Rules / Cannot be zero. A Simple Logic Check is defined:

8.     Review and change the Validation Usage rules if necessary.

9.     Save the Table definition.

10.   Compile the table, displaying Compile Options and selecting Rebuild Table, Rebuild Indexes and Rebuild OAMs:

 

11.   Check the Compile tab to see that the table compiled successfully.