Number series is a great feature in Navision that allows you to use all kids of numbering methods easilty and also allows the application to work the same everythere,
So how do I implement Number Series in a new table. Let's go through that step by step. For this example we will use the Item table to copy and paste from.
Step 1 - Create the table.
A table that has number series has a minimum of two fields. A primairy key field of type code length 20. But also a second field to store the number series. This is a code field as well with length 10.
Go to the object designer and create a new Table. The first field will be created manualy like this.
Please call it No. and not something else or otherwise our copy paste actions will fail.
Secondly we will open the item table in the designer as well. Find the No. Series field and copy/paste this.
Now our table looks like this.
Step 2 - Add the code
When you implement number series in your table, there are three required pieces of code. One in the OnInsert trigger, One in the OnValidate of the No. field and a new function that is always called OnAssistedit.
We will copy and paste this code from the item table like this.
When you are done with the copy/paste action your new table should look like this.
Step 3 - The variables
When you now compile your new table you will get an error message like this.
This is because we have not yet declared the nessesairy variables. We will need two of them, the Inventory Setup table and the NoSeriesManagement codeunit. We can also copy and paste this from the item table.
So our variables are like this.
Please notice that you will still receive the same error after this.
Step 4 - Code changes
In order to have the code compile we have to change it a little bit. The code we copied is reading the inventory setup in a function but that is not nessesariy in our case. We will just read it directly.
So go to the C/AL code and do a find and replace on GetInvtSetup by InvtSetup.GET like this.
Step 5 - Save the table (Twice).
Now we need to save the table, but when we try we'll get this error.
The reason for this is simple to explain. We have created a new field (No. Series) and started using that field in code. But because the table was not saved in between, the compiler does not know that field yet. To solve this we need to save the table without compiling.
And then compile the table from the object designer.
Step 6 - Create your own number series.
If you look closely at the code we just created you'll see that it uses the field Item Nos. from the inventory setup table. There is a high chance that you will want to use a number series of your own so let's create one. We will do this in the inventory setup table as well but this can also be any other setup table in Navision.
Open the Inventory Setup table in the obect designer and copy the Item Nos. field like this
And paste it as number 50000. And rename to Test Nos.
We will also add this to the Inventory Setup Form or page
Notice that we create a new (fast) tab for our field. This is best practice.
Run the form or page and populate the number series.
Step 7 - Change the C/AL code
To use this new number series we need to go back to the code in our new table and do another find and replace action. This time replace Item Nos by Test Nos.
And save the table.
Step 8 - The User Interface
Last step in implementing the Number Series functionality is adding it to the user interface. This is done via the OnAssistedit trigger. We will demonstrate both forms and pages.
Create a new form with the form wizzard or page with the page wizzard.
Now go to the code behind the No. field by focussing on the field and press F9. You will see the four triggers, OnLookup, OnValidate, OnDrilldown and OnAssistedit like this.
Our code will go into the OnAssistedit trigger of both the form and page and is copied from form 30. The Item card.
Now when we run the page or form you'll see that it works and how easy it was to implement.
Its really awesome, thanks a lot to provide in depth information about implementation of number series.
Just wanted to thank you for taikng the time to post this! I Was in the exact same situation and had googled all possible fixes', but none of them really fit my scenario.
I have an issue of updating the same functionality of No. Series for a different field which is not key along with the No. field which is a primary key.Can i Do that?
Hey marq i am really sorry.. i just tried to solve this problem and i am able to solve it.. did a silly mistake.. thanks a lot for this post.. its really helpful for people like us whose are new to Navision. keep Posting
here i didnt get one thing.. where did we set our new No. Series.. Because i try to implement this thing but it showing only 5 No.Series ITEM1,ITEM2,ITEM3,ITEM4 and ITEM5.. but i have to set it to my newly created No. Series.. how can i do it?