Hi,
I'm quite new with Navision so please don't shoot me :-)
I want a field in a table to be mandatory (let's say 'Email Adress'). Also when creating a new record in that table through a form and the user forgets to fill in the 'Email Address' and wants to enter another new record or closes the form I want to inform the user that the Email Address should be filled in, but without (this is very important!) losing all the other entries in the new records!
So, to summarize this : what's the best solution to be sure a field is filled in a record and what trigger(s) do I need to code and where (Table/Form) ???
Thank you very much!
Wim Teuwens
0
Comments
Try using TESTFIELD in code.
As such there is no way make a field mandatory in Navision. Yes, you could put some code in onclose trigger of a form but that would give you hell a lot of problem. The only way to check for mandatory value in a field is while posting. Whenever you post check for the value in the table and flag a error message.
Thanks
Best regards
Suresh
email : sbhatbng@hotmail.com
In most cases however the customer needs only few fields to be absuolutely mandatory. If that is the case, we use the following solution:
At insert, automatically set de value for Blocked = Yes (You could use the InitValue property for this, or add a line to the OnInsert-trigger). The user normally needs to unblock the record before het can use it somewhere else in the application. In the OnValidate trigger of the field Blocked you test whether the fields that you consider to be mandatory are filled by the user. If not create an error. Of course you only perform the test if the user unblocks the record (not if he blocks it). For example:
Blocked - OnValidate
IF NOT Blocked THEN BEGIN
TESTFIELD("E-Mail");
TESTFIELD(Address);
END;
DSA Global Solutions bv
Hoofddorp- The Netherlands
t. +31 - 23 737 0 484
m. http://www.dsa-gs.nl
On Table Level:
- use "not blank"-property for the mandatory field - add following code
On Form level:
- Work with "Delayed insert"
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Maybe you think this will work educational, but most users will hate you for building such a solution!
DSA Global Solutions bv
Hoofddorp- The Netherlands
t. +31 - 23 737 0 484
m. http://www.dsa-gs.nl
Thanks for the replies...
What strikes me the most is that (what to me seems basic development) there seems not to be a one-go solution for this problem. Indeed my biggest problem is that all the fields will be blanked out when there's an error on the form (ex. field not filled in). And yes my customers WILL shoot me :-)
Anyway, I'll try out the suggestions from you guys and hope for the best.
Thanks again.
Set your form's DelayedInsert property to YES, like was suggested. Then put the validation code in your table, not the form, that way the form won't close if there is an ERROR. In both the OnInsert trigger and the OnModify trigger, you do the TESTFIELD, like suggested. You will not be able to insert or modify the record without having a value in your field, and all the other values will be preserved. I use it all the time.
HTH
RIS Plus, LLC