How to Define a Business Rule for a Field

This step shows how to add a "May not be blank" rule to the EmployeeSurname field definition.

Be aware that business rules defined at field level are applied in every table where the field is used as a column. Field level rules should be "universal" rules, such as "may not be blank", or "may not be zero".

If you haven't yet created the field EmployeeSurname, complete Create a Field Definition.

1.     Open the field EmployeeSurname in the editor. You will find this field on your Favorites / Last Opened tab.

2.     Select the Rules and Triggers tab, which will currently be blank.

3.     Open the Add menu from the Home ribbon. This shows six Business Rules options are available:

4.     We will add a "May not be blank" rule to Employee Surname, using a Simple Logic Check.

        Select Add Simple Logic Check from the Add menu.

        The new simple logic check will be listed on the Rules and Triggers tab, and the Details tab will open.

 

5.     Complete the rule on the Details tab, as follows:

Description

May not be blank

Rule Definition

#EmployeeSurname = *blanks

When inserting

Always apply rule(ADD)

When Updating

Always when column is used (CHGUSE)

Condition is true

Return an error (ERROR)

Condition is false

Evaluate next rule (NEXT)

Message Number

clear

Message File

clear

Message Text

Surname may not be blank

        Notes:

      *blanks is a System Variable. See System Variables.

      Always apply rule (ADD) - means that when an application performs an INSERT command to a table which contains this column, the Surname field value must be supplied

      Always when column is used (CHGUSE) - means when an application performs an UPDATE to a table which contains this column, the rule is only applied, if the Surname value is supplied

6.     The rule will now be shown on the Rules and Triggers tab:

7.     Save the field definition by clicking Save on the Quick Access toolbar:

8.     This rule will be implemented when the field is used as a column in a table. The table OAM will include the validation logic whether defined at field or table level. LANSA applications perform all Table I/O via the OAM and validation logic occurs before the table is updated, or a record inserted or deleted.

See Field Rules and Triggers Development.