When a Validation is associated with a data entry field, the corresponding record cannot be accepted unless the field is populated by data that conforms to the validation (i.e. is a member of the associated list, or matches the criterion specified by the formula). To assign a validation to a field:
- Right Click in the field and choose Custom Validation
The Field Validation window will open showing your Custom Validation lists
To assign a Validation List:
- Choose the List to validate against and click OK, or select Make a New List to create a new validation list
If you choose to make a list, you will be able to give the list a name and specify the values. You will need to subsequently edit the list to provide descriptions.
The list will be strictly enforced when associated with a new record; it will not be enforced if you are modifying an existing record, unless you explicitly modify the field associated with the list. Strict enforcement means that the value entered in the field must exactly match (except for case) an item in the list.
Note: Where a custom validation is longer than that permitted in a field, the validation will be truncated and accepted.
To assign a Validation Formula:
- Set the pop-up menu to Require value to match formula
The List will be replaced by a text box
- Enter the formula as a standard MoneyWorks expression into the text box
The variable _value in the expression will reference the text entered. If the formula evaluates to zero (false) the value will be rejected and a warning message displayed. Any other result will be accepted. For example
length(_Value) = 4
Will only accept an entry that is exactly four characters in length.
To include an optional message to display on non-acceptance, terminate the formula with a semi-colon and enter the message text after this. e.g.
length(_Value) = 4;Entry must be exactly four characters
- Click the OK button
If the formula is syntactically correct it will be saved. It can be edited subsequently by again right-clicking on the field and choosing Custom Validation
To make an optional Validation List
Because the lists are strictly enforced, to make one optional you simply need to have an entry in your validation list with an empty item field. It is a good idea though to put something in the description, so it is clear when choosing the item from the Choices window.
This will appear in the list as:
To remove validation from a field
- Right click in the list and choose No Validation
Note: the various types of transaction entry (Payment, Sales Order etc) can have different validation lists associated with the same field.