How to make a field mandatory...newbie question

powerbouwer
Member Posts: 3
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
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 out the NotBlank property for a field in a table.
Try using TESTFIELD in code.0 -
Hi,
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.com0 -
Also check the delayedinsert property.0
-
In the end, it will appear that it is not possible to make a field mandatory. For example: The OnClose trigger is not activated if yoy scroll the records, but only if you close the form. So also this is not a proper solution.
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;Theunis Modderman
DSA Global Solutions bv
Hoofddorp- The Netherlands
t. +31 - 23 737 0 484
m. http://www.dsa-gs.nl0 -
This is also a possibility. However, there is on big disadvantage to this method (which I think is unacceptable): if the end-user forgets to fill the mandatory fields, not only an error will be generated, but also all the data he has entered correctly in the other fields of the record will be gone.
Maybe you think this will work educational, but most users will hate you for building such a solution!Theunis Modderman
DSA Global Solutions bv
Hoofddorp- The Netherlands
t. +31 - 23 737 0 484
m. http://www.dsa-gs.nl0 -
Hi all,
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.0 -
I don't understand, there is a very simple way to do this. Granted, Navision is by no means a sophisticated development environment like Visual Studio, but it gets the job done in no time.
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.
HTH1 -
21 years later and this discussion and solution is still proving useful, thanks all!0
-
The final result for "mandatory" fields is: Users use any value (in most cases wrong) to overcome this step. And wrong value is worst then empty value.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions