Executed when user input is validated.
Applies To
Fields
Remarks
This trigger is executed after the default validation behavior. An error message displays if an error occurs in the trigger code. In case of an error, the user entry is not written to the database.
Differences Between the Classic Client and RoleTailored Client
We recommend that you carefully consider the code that you use in OnValidate triggers. In the Classic client, if a user encounters a validation error the user will not be able to enter input in any other field. In some cases, the user is not able to fix the validation error and must close and re-open the form to enter the correct values. For example, Table 225, Post Code, has an OnValidate trigger for the City field that checks whether the Code field is empty. On Form 367, Post Codes, the Code field is placed before the City field. However, if a user chooses to enter the city before entering the postal code, a validation error occurs and the user cannot enter input in the Code field to fix the validation error. The user must close Form 367. When the user closes the form, the data that was entered is not written to the database because of the error. The user can re-open Form 367 and enter the postal code before entering the city.
In the RoleTailored client, if a user encounters a validation error this problem does not halt the user because the user can enter input in other fields. For example, if a user uses Page 367, Post Codes, and enters a value in the City field before entering a postal code value in the Code field, then a validation error occurs. In the RoleTailored client, the user can then enter a postal code value in the Code field. When the OnValidate trigger runs again, the validation error does not occur. When the user closes the page, the data is written to the database.
Another example is Form 42, Sales Order. In a sales order line, if a user selects Item in the Type field and then in the No. field the user types one of the resources instead of one of the items, the following validation error occurs:
Item No. ' <resource entered> ' does not exist.
One way to fix the validation error is to change the Type field to Resource instead of Item. However, in the Classic client you cannot enter input in any field other than the No. field after the validation error occurs. To fix this error, you must instead remove the input from the No. field and then you can change the input in the Type field. In the RoleTailored client, after you get the validation error, to fix the error you can change the Type field to Resource instead of Item.
See Also
© 2010 Microsoft Corporation. All rights reserved.