Purchase Order: Quantity To Invoice = 0

Hi To avoid wrong postings (in case of more than one invoice per PO Line) the field ‘Qty. to Invoice’ should always be empty except the user fills data in it. How can I solve this? I tried it with: **Table 39 / PO Line** **InitQtyToInvoice()** "Qty. to Invoice" := 0; "Qty. to Invoice (Base)" := 0; But this delets also all inputs in this field by the user [:(]. Any ideas out there? bye André

Hello Andre, Change the line InitQtyToReceive; in the OnValidate trigger of the field Quantity to the following statement: IF ("Document Type" <> "Document Type"::Order) THEN BEGIN InitQtyToReceive; END ELSE BEGIN IF (Type <> Type::Item) THEN InitQtyToReceive; END; Saludos Nils

Hi Nils muchos gracias [:D]! You lead me in the right direction. It works (with a minnor change). IF ("Document Type" <> "Document Type"::Order) THEN BEGIN InitQtyToInvoice; END ELSE BEGIN IF (Type <> Type::Item) THEN InitQtyToInvoice; Question 1B [:p]: Is it possible to set the field also empty while closing the form? If the user fills in a quantity and doesn’t post it. TIA bye André

I thinks so… you’ll need to add the code to Form 50, in the OnCloseForm trigger, Rec will be the current record, so you simply need a loop that sets the corresponding quantity to invoice / quantity to invoice (base) to zero… Saludos Nils

It’s a better idea to use onQueryCloseForm than onCloseForm… an error on onCloseForm is deathly to navision (the client will probably crash).

That will work when the user closes the form, but not when they go to a new record. Adding that code is usually more of a hassle than it is worth as as Alfonso says, alot of the Form Triggers are extremely picky.

Hi Thank you to all. I added in Form 50 the following code: **OnQueryCloseForm() : Boolean** xPOLine.SETCURRENTKEY(xPOLine."Document Type",xPOLine."Document No.",xPOLine."Line No."); xPOLine.SETRANGE(xPOLine."Document Type","Document Type"); xPOLine.SETRANGE(xPOLine."Document No.","No."); IF xPOLine.FIND('-') THEN BEGIN REPEAT xPOLine."Qty. to Invoice":= 0; xPOLine."Qty. to Invoice (Base)":=0; xPOLine.MODIFY; UNTIL xPOLine.NEXT= 0; END; It seems to work [:)]. @Chris: Exactly this should happen. The user should be able to fill data in ‘Qty. to Invoice’ in each PO Line but if he closes the form without posting an invoice all fields ‘Qty. to Invoice’ should be cleared. bye André