6.4.1 Field Validation Rules and Triggers
The Repository allows you to define validations and business rules at field and file level. If multiple validation are required, each can have its own error message. Using LANSA's validations, rules and triggers, application code significantly reduces application code and future maintenance.
This is a brief list of the types of rules you can use:
- Range of values to check a field against a range of values, such as: is the applicant's age between 17 and 66? There are 20 ranges available for each field.
- List of values to check a field against a list, for example, M or F for male or female.
- Table/file lookup is used to check a field against a value in a file or table. For instance, is the product number in the product master file?
- Evaluate an expression allows a series of conditions to be evaluated. For example, is item weight less than (item volume * 10.643)? The expression can be up to 395 characters in length.
- Call a program allows you to use a LANSA function or 3GL programs. For instance, is the premium within the range for the factors supplied?
- Validate a Date will check that a date is in the correct format and/or range. For example, is the Delivery Date in format DDMMYY and within 45 days?
Each error condition should have its own error message. The error message will only be displayed when the actual error occurs.
Triggers can be used to initiate an action, but only when the specified conditions occur. While triggers are file based, they can use field conditions to determine if an action is required. For example, to initiate the production of a delivery note, but only when a new item is added to an order and if the customer's credit limit is not exceeded. On a change of order, a different process altogether could be triggered.
The sequence of the validations is important, so before attempting to use them make sure that you read Field Rules/Triggers in in the .