I’m an experienced Windows programmer, but fairly new to Navision. What is the best way to make a data field require an entry, i.e. force the user not to leave a field blank? There seem to be several alternatives, each with different effects. Thanks for any help. Sam Bartley sbartley@sysaccmgtco.com
Probably the easiest way is to set the property NotBlank to Yes for the field in the table. John
I have also tried to figure out how to solve this the easiest way. The NotBlank property works only after the user changes the field, so if you want to be sure the field is not empty, for example when a new record is inserted (but the user has not made actions on the field), you will have to add code to various triggers to test the field value. This might need some lines of code, since you cannot easily cancel the move to another record (OnNextRecord) or closing the form (OnCloseForm). I sure would like those VB like Cancel-parameters on the triggers… The triggers I dealt here are Form triggers, you may want to create this functionality on the table level, which would of course be the normal thing to do. But since this kind of functionality may have some drawbacks elsewhere (if you are hacking basic Navision tables), it may be a good idea use the form triggers. /Pauli
Let’s not forget to keep the “Navision Rule” in mind: Check the data when it is to be used, not at entering. As Pauli stated, you may end up with adding lots of code to do the checks, which might become inconvenient later. As a compromise, we have used for some of our clients the method of attending the user to the important fields by giving these a different background color (yellow works fine usually). John
Sam: It´s also a good idea to set the of a field in the table definition with the most probable value. It´s not bullet-proof but it works in most cases. Regards Alarich
I can tell you from experience that is nearly impossible to catch every situation that the user might use to “get around” a field. Other that following the standard Navision philosophy the only surefire way to trap it is if you are certain that a user will enter a certain field after the one you are trapping for. Even this is not a fail safe since Navision is an event driven system. Bill Benefiel Manager of Information Systems Overhead Door Company billb@ohdindy.com (317) 842-7444 ext 117
These are all very good suggestions. Thanks to all who responded. Sam Bartley sbartley@sysaccmgtco.com
1°Put the property “Not blank” at yes. 2°In the trigger “ON INSERT” for the table use the function testfield exp:TestField(“Customer Name”) This function make a run time error when the field is empty. 3°After this opération : check all the form allowed to insert a record for this table and put the property “Delayed insert” at yes.
I haven’t tested this, but…If you put an error in the OnInsert trigger, won’t that disregard the insert and you’ll have to start over again? I know that you can cancel changes made to a record by doing something similar in the OnModify trigger. Mark Keener Automated Number Crunching Dayton, OH USA
Mark, is not true because you use the property “Delayed insert” in the form. The system insert the record when you go to an other record and not when you go to an other field non member of the primary key