field property "not blank"

I am working with a client as project manager (not a nav expert) and they need to make a field on the custoer card “required” for data integrity purposes. There is a field property of “not blank” but it doesn’t seem to work. People can still set up new customers, vendors and not fill in info for the “required” field.

Any info on how the “not blank” property is supposed to work? or other alternatives?


yeah isn’t that stupid [:|]

It works if there’s a value in the field and you want to remove it. Try it, enter something in the field, save the record, then try to delete the value, it will scream at you. Absolutely useless to force people to enter something in it. I think though it’s meant to be used in combination with the InitValue property. Set up a default value in there (which I don’t like to do), and the NotBlank property will keep users from blanking out the field.

Can you use TESTFIELD in OnValidate(), either in the tale or in the form, to check the blank? I am not an export either!

Hey Couber, spreading your wings here huh [Y]

I guess you could go that way, but then the Customer Card wouldn’t behave in a predictable way anymore. You wouldn’t be able to create a new customer, and you’d have to modify the Customer Card to allow field entry before actually inserting the record. You’d almost have to have a form to enter initial values, which would work nicely, but won’t feel like NAV at all.

It’s just not the ‘NAV way’ to enforce mandatory fields. The only way that I can think of that will really work well in NAV is to use some kind of template model, where you select a customer template in which you have the mandatory fields already filled in. That way you can use the NotBlank property also to make sure users don’t remove the value.

Or the Blocked Method. An new customer by default on insert makes Blocked = True.

& when you want to uncheck the field it does a check of your fields you want to be mandatory.
if any of them is not filled in it won’t let you uncheck the blocked field therefore not allowing that customer or item or vendor/etc to be used.

You’re right Harry I forgot about that one. That’s actually the easiest to implement.

I have two prefered methods. On eis the Default to blocked suggested by Harry. This is the nicest “Navision” solution, and the easiest to maintain.

For clients that are a little more persistant, I use the Traffic light system. In this I add a function to the table that returns a status if fields are entered or not. Clasified as must be entered or should be entered. (With variations for different clients). Then I add a red orange or green dot to the top of the card, and in the list form.

This way, it is clearly visible which customers or items etc are incomplete. Combined with the default blocked method, its a good solution for the most finicky of clients.

One word of warning about mandatory fields. I have seen many partners write code in the on close and on next triggers in forms to do this. I wont go into the reasons (becasue there are many), but really you should never do this.

So in any case the first step is to convince the client to go with Harry’s solution.

Initially the property only works on primary-keyfields when a record is inserted with TRUE-parameter, then (as mentioned above) on changing fields.

Thanks Harry, the “blocked” approach should be perfect for what we need.

Thanks David - this is great information, I will suggest that they use the “Harry” method, If it doesn’t provide enough information to the user we can go with the traffic light approach.

Craig Boyle

Thanks for the information!

I am the client DenverCraig referred to in his initial post. I have a few years of NAV experience. 1st installation, though. I assume that I would set in the Customer card, Blocked field, InitValue property to ALL (our options are [blank], ship, invoice, all). I then also set up any other fields I want to be mandatory by changing their NotBlank property to Yes.

Todd Shilhanek

Hi Todd, and welcome to The Dynamics User Group.

Actually that’s close but not quite. This mod will need help from your partner to wrtie some code, but basically its pretty simple.

Basically in the on validate trigger of the “blocked” field you add code like

Testfield('My Field 1");

Testfield('My Field 2");

Testfield('My Field 3");


This way when you try to unblock the customer you won’t be able to till you fill in themissing fields.

of course I have seen typical cases where we go back and see that a "mandatory field such as Customer Order number etc is filled in with “-” or , etc. So don’t think of this as a suitable replacement to training as many people try to do. [;)]


I was hoping we would be able to do this without our partner, but I completely understand the need for the TESTFIELD() function. Our partner and us talked about putting it on the order header when a customer is chosen, but I like it better on the Customer and Item Blocked fields. That way, it is on the customer/item creator to get it right, not the order takers to notice it is missing!

So, if the TESTFIELD() function is called, do I still need to have NotBlank = Yes?



No thats what the testfield function does. The problem with the NotBlank is that it is not triggered. You could set NotBlank, then use VALIDATE on the fields, but I just prefer the testfield as its clearer what is happening.

Cool. Thanks.

I always set not blank to yes on fields i want “mandatory” - it’s the “better safe than sorry” approch. I validate on the “click” of the blocked field - but once all fields are filled the “not blank” will stop someone later on from accidentily clearing a field. It will allow them to change it but not blank it out.

Actually yes you are right, that would be safer.

Again, thanks for this great information. We had our implentation team make the changes to the code. I have tested it and like the fact that if I unblock and navigate away from the customer/item/vendor it gives a warning and brings me back to the card in question. What is a little troublingis that when I come back to the card several of the fields I entered data into have been wiped out. It was my understanding that NAV will save the data as soon as you navigate away from a field. Why then on this validation process do I have data wiped out from fields, especially ones that tested fine through the initial validation?



Sounds like a question for your implentation team that made the changes to the code.

Perhaps they did something using the property DelayedInsert=YES??

This is because you have an error, and if there is an error the data is not saved. Its why NAV doesn’t have this sort of process as standard.