Progress
ADM 2 Guide


Field-level Validation Procedures

You can define field validation procedures (also called column validation procedures) in the SmartDataObject for each updateable field in the temp–table. To do this, you define an internal procedure named columnValidate that takes the column value as an input parameter. Each time the SmartDataObject receives an updated field from a client object, the submitRow function in the super procedure data.p runs the field validation procedure (if any). The procedure receives the field’s value as an INPUT parameter. If the validation fails, the procedure can signal an error and log a message by RETURNing the message text. This message is displayed to the user as the error text, and in the visualization, focus is applied to the invalid field.

The field-level validation procedure allows more extensive value checking than the logical ValExp (schema validation expression) permits. Note that because the schema validation expression might not always be executed in the client visualization, it is a good idea to duplicate any important checks in the SmartDataObject field validation procedures. Note also that the field validation procedures are executed only if a field value changes.

NOTE: To work around the restriction that field-level validation executes only when a field value changes, use record-level validation instead of field-level validation. This works because the record-level validation procedure can access any field in the row object by name. For details, see the "Record-level Validation Procedures" section.

The following example, which utilizes the Progress sample database, describes a SmartObject application that implements a field-level validation procedure in a SmartDataObject. Specifically, it creates field-level validation that ensures that application users enter OrderLine quantities that are greater than zero.

Follow these steps in the AppBuilder to implement this example:

  1. Create a SmartWindow.
  2. Create a SmartDataObject for the OrderLine table in the sports2000 sample database.
  3. Create a SmartDataViewer for the OrderLine table, using the SmartDataObject created in Step 2 as its Data Source.
  4. Drop the SmartDataObject and SmartDataViewer onto the SmartWindow and link them with Data and Update links.
  5. Drop a Navigation SmartPanel onto the SmartWindow and link it to the SmartDataObject with a Navigation link.
  6. Drop an Update SmartPanel onto the SmartWindow and link it to the SmartDataViewer with a TableIO link.
  7. Create in the SmartDataObject an internal procedure called QtyValidate that has the following code:
  8. DEFINE INPUT PARAMETER valqty AS CHARACTER NO-UNDO.
    
    IF INTEGER(valqty) = 0 THEN RETURN 
    "Order Line quantity must be greater than zero".
    
    END PROCEDURE. 
    

With this field-level validation procedure in place, an application user who enters zero for the Order Line quantity receives the specified error message, and focus is applied to that field in the SmartDataViewer. Note, however, that if the initial value of the Order Line quantity is zero and the application user does not modify the field in the visualization, the validation does not run. This is because field validation procedures are executed only if a field value changes.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095