RE: Modify a field on Purchase Header
Hi mjcjyk,
Just a quick comment (if you know this already, you can skip to the next paragraph): The Vendor Invoice No. field is meant to be populated with the invoice number provided by the vendor so that it can be referenced at a later time in the Vendor Ledger Entries, payments, etc.
Assuming you're writing a Processing Report in NAV with Purchase Header as a dataitem, it should be pretty easy to create a variable of type Integer (let's say we call this variable VendInvNo), set it to a starting value of something like 10000, and then use it in the OnAfterGetRecord trigger set the value of the Vendor Invoice No., and then have it self-increment with a statement like:
VendInvNo := VendInvNo + 1;
That way, when the report loops back in with the next record, the next PO will get Vendor Invoice No 10001, and the next one gets 10002 and so on.
If you wish to make it alphanumeric, then you can follow the same concept but concatenate this variable with an alphabetical prefix (defined as a constant) before filling in the value in the Vendor Invoice No. field.
Or, you could also create a No. Series in NAV for it, then use the No. Series Management codeunit to find the next available number and use it (and the codeunit is responsible for autoincrementing).
I hope this helps. If my response has answered your question, please verify by clicking Yes next to "Did this answer your question?"