Having seen a couple of posts on data validation coming by I decided to tackle this issue in a couple of blogs of which this one is the first. Just to straighten out me thoughts and knowledge on this, and share it with you.
Like in any other software system NAV will validate data, entered by a user, before it will allow it to be recorded in the database. This validation process is triggered, once a field has been populated and the user leaves the field. This might be for example by:
In NAV data validation can be seen as a three step process in the following order.
Based on the properties of the field the system will check whether the data entered complies to each property. As an example let's take the Quantity field on a Sales Invoice.
One of the main properties of any field that will be validated is the Data Type property. Being Decimal for our Quantity field this means that only decimal data can be entered into this field and any deviation from that should lead to an error thrown by the system. Like typing the text error in this field:
Next to system validation, i.e. checking the data entered against default properties of the field, a NAV developer has the possibility of programming additional checks and actions on any field. This is done by writing C/AL code on the OnValidate trigger of the relevant field.
As in the example of the Quantity field we see that quite some code has been written (even more than shown in this screen shot).
A third and last level of data validation is given on the UI (user interface), being the OnValidate trigger on to the form control Quantity field:
In case of our Quantity field no validation code has been provided on the UI. Note, however, that action will be taken based on code in the OnAfterValidate trigger after validation as discussed in this post.
Much Appreciated. Thanks Luc. Perfect explanation.
Good information ; very useful
Keep posting stuff like this i really like it.