Sequence Number navision.

I have created my number sequence in navision ‘PA-00001’ - ‘PA-99999’;

In the code i am writing the following code to generate the next number from my sequence.

Num := NoSeries.GetNextNo(TransferSeq,TODAY,FALSE);

It generates but didnt save the last value.

how to save last value

Look at how other number series do it. Take a look in Customer, Sales Header, or any of the tables that use number series do it. You’ll see you don’t quite have it right. You can look in the OnInsert triggers of these tables.

Here is my code that i am using to generate the number. I have created the number sequence.

I am using the following code to generate the number sequence and to insert the record in transfer header table. The problem with this code is that it is not saving the last sequence value every time i open the form and run this code it starts with 1. Please help me correcting this code so that i can get it work. I have created a customized form and on the button click event i wrote the following code.

Num := NoSeries.GetNextNo(TransferSeq,TODAY,FALSE);

TransferHeader.“No.” := Num;
TransferHeader.“Transfer-from Code” := ‘1001’;
TransferHeader.“Transfer-to Code” := ‘1004’;
TransferHeader.VALIDATE(“Shipment Date”,TODAY);
TransferHeader.VALIDATE(“Posting Date”,TODAY);
TransferHeader.“In-Transit Code” := ‘TRANSIT’;
TransferHeader.INSERT;

Thanks and regards.

I’m not going to write the code for you. You must not have taken the original advice. Look in the OnInsert methods of those tables to see how to properly use the No Series Management codeunit to assign numbers to your records / fields.

Thanks Matt but if you can help and adjust the same on my example code i would be thankful.

Because there they are writing in the On-Insert trigger at table level but here i want to write on click so i don’t know how to map it and work it out.

Please help.

The answer to your question is exactly as Matt has explained, regardless of where you intend to put your code. Follow Matt’s instructions and you will know how to change your code in your on-click trigger.