Tuesday, February 25, 2014

Dynamics NAV - How to Update a value in the current record

This example updates the posting date to the current date when a user attempts to post a specific warehouse shipment

---------------------------------------------------------------------
WhseShptHeader.COPY(Rec);  //Copy the current record to memory
Rec := WhseShptHeader; //Set rec = current record

WITH WhseShptHeader DO BEGIN
  SETCURRENTKEY("No."); // Go to the record currently displayed
  SETRANGE("No.","No."); //Limit the records to the range of records displayed

MESSAGE(FORMAT(TODAY)); //Format date a text and display it on screen as message box
WhseShptHeader."Posting Date" :=TODAY; //change posting date to today's date for this record
WhseShptHeader.MODIFY; //Modify the record
COMMIT; //only necessary if doing multiple modifies
END;
CurrForm.WhseShptLines.FORM.PostShipmentYesNo;
-----------------------------------------------------------------------

No comments:

Post a Comment