Dynamics NAVProcedure to create custom No. Series in Dynamics NAV
No. Series is used to create records in Dynamics NAV with unique numbers. Unique numbers are assigned to data records automatically using No. Series. The format to be used for the No. Series should be set up initially once which consists of a combination of numbers and alphabets.
Microsoft Dynamics NAV
In this article, I will be demonstrating the procedure to create a custom No. Series in a custom table.
- Create a new field in Table 311 – Sales & Receivables Setup which will save the No. Series selected.
Navigate to the properties of this field and in TableRelation property select Table 308 which is ‘No. Series’.
Add the newly created field ‘CF_CreditNoteEntity’ to the Page 459 – Sales & Receivables Setup so that it is accessible to the user from the NAV windows or web client.
- Now create a new field ‘No. Series’ in a custom table with Data Type ‘Code’.
Navigate to the properties of the No. Series field and in TableRelation property select Table 308 which is ‘No. Series’.
Note: ‘No.’ field is the primary key of the custom table which will save the unique No. Series.
- Create two new variables in C/AL globals in the custom table.
a. SalesSetup of DataType ‘Record’ and Subtype ‘Sales & Receivables Setup’ which is Table 311.
b. NoSeriesMgt of DataType ‘Codeunit’ and Subtype ‘NoSeriesManagement’ which is Codeunit 396.
- In OnInsert() trigger of the table add the following code:
- In OnValidate() trigger of the primary key field which will save the unique No. Series add the following code. In this scenario, I have added it to the OnValidate() trigger of ‘No.’
- Go to ‘No. Series’ which is Table 308 and create a new entry for the No. Series to be used.
To generate ‘No. Series’ automatically you need to select ‘Default Nos.’ checkbox. If you also want the field to support manual nos. then you should select the checkbox ‘Manual Nos’.
The ‘Last No. Used’ field gets updated automatically when a record is created and the unique No. Series is inserted in the table.
- Navigate to Sales & Receivables Setup which is Page 459 and select the No. Series for the newly created field in step 1 from the drop down list.
- Hence, automatically when you create a new record, the No. Series will get inserted and a unique record will be created.
Thus following this procedure, a custom ‘No. Series’ can be created for a custom table with any combination of alphabets and numbers which will create unique records.