Validation For the Item No...

Dear Friend’s I am trying to validate certain fields in the Item Card… my problem is the item should not be added if those fields are blank… Regard’s

Validate Your records on the OnqueryClose Trigger of the Form For Ex IF “Shelf No.” = ‘’ THEN BEGIN // VALIDATION OF THE RECORD DELETE; // DELETE THE CURRENT RECORD END; Or you can Throw an Message by using Error(). So that it wont let you continue.

Thank u very much ashok …

Hi, Change the NotBlank property for ItemNo to Yes

sorry Ashok there is a problem by doing this… like if u create a new item and then go to the next or previous record the validation is not happenning… regard’s

You have to set the Item Card Form property DelayedInsert to Yes. Then, at table level, use OnInsert and OnModify triggers with code like: TESTFIELD("My Required Field"); TESTFIELD("My Required Field 2"); I’m pretty sure this has been covered before, search the forum for “TESTFIELD DelayedInsert” and you are bound to find something useful.

quote:


Originally posted by nelson
You have to set the Item Card Form property DelayedInsert to Yes. Then, at table level, use OnInsert and OnModify triggers with code like: TESTFIELD("My Required Field"); TESTFIELD("My Required Field 2"); I’m pretty sure this has been covered before, search the forum for “TESTFIELD DelayedInsert” and you are bound to find something useful.


this will work, just watch out for those fields with lookup that thinks the record has already been inserted, for example is the base unit of measure.

quote:


Originally posted by bobby_ph this will work, just watch out for those fields with lookup that thinks the record has already been inserted, for example is the base unit of measure.


That’s why DelayedInsert property needs to be Yes.

quote:


Originally posted by Arthur


That’s why DelayedInsert property needs to be Yes.
[/quote]
yes, but in the case of the item card, it has been designed to be inserted as soon as you input an item number and leave that field. when DelayedInsert is set to Yes, you will not insert the record until you leave the current record, but in some of the fields, specially those linked to other tables, a relation has to be made to an existing item with a valid item number first(because the code was written to assume that the record has been inserted when the user left the item number field). these are the cases that you need to look for and do the necessary changes, setting DelayedInsert to Yes will not usually work alone. :slight_smile:

Navision is not good at this. They have set up the system to do all checking at Posting…If you want to do anything else, it is a bit of a hack. Some options are basically: (1) Use the delayed insert. The issues are as discussed above. (2) Do the checking on Posting. (3) Insert the Item with the Blocked = True and check the fields when the item is unblocked…This is probably the closest to what you want.

Dear Friend’s Thank u all very much …my initial tests seems to be sucess… Thank u all once again Prem

Dear Robert Yes what u said is correct … i am having problem with the UOM field… how to get rid of this…? Regard’s Prem

Hi Prem, Create a new form and run it at the On-Insert Mode, This form must not be bound to the Item Table. Then have variables of the same properties as those field you have on the Item Card you want to validate. Validate these fields and then use a PushButton or a boolean to insert the item. By doing a testfield you will still loose the Number from the number series although you are deleting. And Delayed insert does not help for UOM fields. Hope this can help.

Dear Prashanth Thanks for ur reply… since i am using manual no series i have no problem about loosing no series… is there a way to do it without adding a new form… i mean by modifying either the item table or card…? Regard’s Prem

quote:


Originally posted by prem_kumar_25
Dear Robert Yes what u said is correct … i am having problem with the UOM field… how to get rid of this…? Regard’s Prem


hmmm… because the field for the UOM in the item table has a direct table relation to the item unit of measure table. how to get rid of it, I’ll look at it later today because I don’t have a ready answer for this, it’s still working hours around here :). and when we do find the answer in adding the UOM, you will still have to add another code for deleting them in the UOM table if the item was discarded without being inserted in the table.

There’s another way to handle, less complicated than work around delayedInsert you can use the blocked flag Check the required field, and set blocked to true and you could show a warning and/or store the failed conditions in comments If you use blocked flag, you have no code to write to prohibit the use of the item You will have no problem with related table like UOM or else and i think this solution is nearest navision standard It’s possible to enhance this method : add a boolean field ‘Invalid’ You can check if invalid item records exists and delete it (with a key on Invalid it would be faster) Best regards Patrick

Hi Prem, If you dont want to use a new form try a Dialog Window.

I wouldn’t use a Dialog for inputting data. It just goes against Navision’s err… humm… well-crafted graphical design… [8D] But that’s just my personal preference. [;)]

I too agree with u nelson… Prasanth i have 7 mandatory fields … Regard’s

Ultimately, the solution with the Blocked field looks pretty good. On the Item table, change the InitValue property of this field to Yes. Then you can be sure that whenever you create a new Item (user action, INIT function, etc.), it will be marked as “useless”. Run the TESTFIELD’s when Blocked is marked as No and be done with it. Finally, a little user training will make sure the solution is running smoothly.