ModifyPurchaseLine(VAR DocumentNo : Text[50];VAR DocumentType : Text[30];VAR ItemNo : Text[30];VAR OrderedQty : Integer;VAR QtyToReceiv IF DocumentType = 'Order' THEN BEGIN // record initialisation recPurchaseRecord.INIT; recPurchaseLine.INIT; // filtering header record recPurchaseRecord.SETFILTER(recPurchaseRecord."No.",DocumentNo); recPurchaseRecord.SETFILTER(recPurchaseRecord."Document Type", 'Order'); // filtering line items recPurchaseLine.SETFILTER(recPurchaseLine."Document No.",DocumentNo); recPurchaseLine.SETFILTER(recPurchaseLine."Document Type", 'Order'); recPurchaseLine.SETFILTER(recPurchaseLine."Line No.",'<>0'); IF recPurchaseLine.FINDSET THEN BEGIN // if rows exists recPurchaseLine.SETFILTER(recPurchaseLine."No.", ItemNo); //filter the item no IF(recPurchaseLine.COUNT>0) THEN BEGIN REPEAT // calculating the quantity that can be received QtyThatCanBeReceived := recPurchaseLine.Quantity - recPurchaseLine."Quantity Received"; // new received qty , should be eixsting qty to recieve and new incoming qty NewReceivedQty := recPurchaseLine."Qty. to Receive" + QtyToReceive; IF QtyThatCanBeReceived >= NewReceivedQty THEN BEGIN recPurchaseLine."Qty. to Receive" := NewReceivedQty; // set new qty recPurchaseLine.MODIFY; // modify record set. //Commit; clear( recPurchaseLine); clear( recPurchaseRecord); EXIT; END; // clearing the calculated fields for line QtyThatCanBeReceived := 0; NewReceivedQty := 0; UNTIL recPurchaseLine.NEXT = 0; END; END ELSE BEGIN MESSAGE('NOT IMPLEMENTED'); END; END; ProcessPoToReceipt(VAR DocumentNo : Text[50];VAR DocumentType : Text[30]) status : Boolean IF DocumentType = 'Order' THEN BEGIN recPurchaseRecord.SETFILTER("No.",DocumentNo); recPurchaseRecord.SETFILTER("Document Type",DocumentType); recPurchaseRecord.INIT; IF recPurchaseRecord.FIND('-') THEN BEGIN recPurchaseRecord.Receive := TRUE; // SETTING PROPERTY TO RECEIVE IF cuPurchPost.RUN(recPurchaseRecord) THEN BEGIN message('processed'); status := TRUE; END ELSE BEGIN message('not processed'); status := FALSE; END; END; END;
Answers
You need to use the VALIDATE command instead of assigning ( := ) as there are other fields updated when you enter a value in manually e.g. "Qty. to Receive (Base)"
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
regards,