The ability to check data input by users is one of the features normally required by any data entry system. 

To implement Formwork validation use EventsProcedures and a Global Error Handler.


 

Example:


A column cannot accept a value higher than 100 - if another column has not been defined as "Custom". 

This validation logic has to be implemented in a Procedure associated to the column in the "Before Write" Event, which carries out these actions:


  1. It obtains the Diff table related to the current operation (see What appens when a User performs a Write?)
  2. It reads the Diff table with the ExecuteReader activity
    1. If the read table has zero records, the user is not writing anything new and it stops running
    2. Otherwise, the operation continues
  3. It verifies that the values higher than 100 are on fields having the 'Custom' flag set
  4. Otherwise, the activity ThrowException throws an exception with an ad-hoc message (e.g., a code error, say 'ERROR-CODE-0032') for the error manager. It notifies the violation and the procedure finishes with a write abort.


The error handler, when set up properly, will be aware of any exception with an 'ERROR-CODE-' message. 

Once an intentional exception has been detected, the handler will extract the code and send the user a more user-friendly message.