Mandatory fields

Can anyone tell me a simple way of making a field mandatory on entry. The problem I have is a customer wants the Standard Cost on the item card always completed when a new item is being created. The NotBlank property for a field only seems to work if that field is part of the primary key! Thanks

Try TESTFIELD(“Standard cost”) in th OnModify Trigger. That should do the job for You.

Thanks Lars that goes some of the way but I really want something that wont let them out of the record until they complete the field. With the TESTFIELD on the On Modify trigger they can accept the message and then carry on withou tentering the Standard Cost. Simon

Hi This is not a new discussion. Check www.mynavision.net and seach for mandatory. But sorry, there is no clear cut way of making madatory fields in NF. Regard

If they want a value when the record is created, place the TESTFIELD in the ONINSERT trigger, instead of the OnModify trigger. If the value is 0, the testfield will generate an error that will prevent them from inserting the record. In addition, if they want to ensure that the value is never manually set to 0, add a testfield in the OnValidate trigger for the field.

Here’s my take on this discussion: Godders’s customer wants Standard Cost to always be something other than zero. I’m sure they have told him many times that Standard Cost must always been filled in. They are NEVER EVER under ANY circumstances going to want Std. Cost to be ANYTHING other than zero. This has been included in the specs, which the customer has signed off on. Right now, it is perfectly clear that Std. Costs are always under every set of circumstances going to be non-zero! HOWEVER: some day in the future, the customer is probably going to tell you that they want some item(s) to have a standard cost of zero. They will call you dirty names because the system won’t let them create an item with a zero standard cost. And they won’t even tell you why they’re calling you dirty names: they will just say “The inventory card doesn’t work.” My first reccomendation would be to simply do nothing— don’t change anything in the system. Let standard cost be one of those things the customer can fill in for herself whenever she needs to-- just like the description, the weight, etc. My second reccomendation might be to create a dialog box which warns the user that the item has a zero Std. Cost without absolutely requiring the cost to be zero— because you just know that someday in the future, for some reason which they’re not telling you now, they’re going to want to create an inventory item with a zero standard cost. ------- Tim Horrigan

Thanks Guys I’m overwhelmed by the response! I have ended up after discussion with the customer taking a bit of a hybrid approach and taken Tim’s second recommendation on board. They now have a warning on the OnAfterGetCurrRecord trigger and the Item No displays as red if there is no Cost and if they cant respond to that then thats their problem. Its still not quite what I or they wanted despite Tim’s warnings of Doom! But thanks anyway. Roll on Sydney 2000 and Come on Aussie.

If you want do have a mandatory field in a card form, then try this: First: Create an error in OnQueryCloseForm, if your field is empty. This way the user is not able to close the form without an entry in your field. Second: In the Trigger OnAfterGetRecord you insert some code that checks if the xRec is complete. If it’s not - you jump back to the xRec. This way the user is not able to jump to another record, if your field is empty. This one works for the Item-Card and the field XXX … in OnQueryCloseForm … > IF XXX = ‘’ THEN > ERROR(’…’); in OnAfterGetRecord … >IF (“Nr.” <> xRec.“Nr.”) and (xRec.“Nr.” <> ‘’) THEN BEGIN > IF xRec.XXX = ‘’ THEN BEGIN > Rec := xRec; > xRec.TRANSFERFIELDS(Rec); > CurrForm.UPDATE(FALSE); > MESSAGE(‘Please …’); > END; >END; Regards, Richard

RMotzer’s routine is good if you only want to enforce the nonzero std., cost rule on the form. In this case, that seems reasonable, since 99.99% of the time an item will be inserted using the Item Card form. This way, you don’t run into trouble if (for example) the user later tries to import some item records from a vendor’s catalog using a dataport. ------- Tim Horrigan