In a previous post I explained how to create a new Number Sequence in a existing module (Working with numbersequences – new NumberSequence). In this post I will explain how you can create a new Number Sequence-module.
I will create a new module called TEST (lack of inspiration).

In Ax3.0 it is pritty simple. You know that the RecId was a int value and with the function ‘maxInt()’, you get the value.

In Ax4.0 and higher, the RecId is changed from a regular int to in64. There is no such function as ‘maxInt64()’ so you cant use this. In the ‘Global’, I found a method called ‘maxRecId()’.
So you just call this method and you will see that the maximum value of a RecId is 9223372036854775807 (I hope I didn’t mistype) or 2^63-1.

When you want to create a table were you want to remain the position of the records you create (like the lineNum field on the SalesLine), you just need to define a field on your new table as a ‘CounterField‘.

When you want a filebrowser on your form and you only added a field that extends from the Extended Data Type FilePath, you wil get a stack-trace/error message when you click on the folder icon. Don’t panic, there is nothing wrong with your AX. Like the error explains you just need to provide the form with the method filePathLookupTitle.

When you want to create a new NumberSequence in AX you have to do the following steps:
1. Create a new Extended Data Type (EDT). Often this EDT extends from num. (this step is not mandatory, but it is a best practice)

2. Discide in witch module this new Number Sequence Reference (classes NumberSeqReference_…) should be included and find the corresponding NumberSeqReference class. (ex. module sales –> NumberSeqReference_SalesOrder)

3. The loadModule() method shows a number of blocks of code, which creates records in the table NumberSequenceReference.

4.Copy a block and change the following fields:
* DataTypeID is the type Id of the new data type.
* referenceLabel is the description shown in the left column of the Number sequence tab on the parameters form.
* referenceHelp is the longer description of the reference shown in the top part of the Number sequence tab of the parameters form.
* sortfield defines the sequence that the references are displayed on the Number sequence tab of the parameters form.
* The wizard fields are default values when using the wizard to create a numbersequenceexample:

Normaly you try to avoid using AnyType variables, but sometimes you are forced to use them. When you use a AnyType enum and you want to cast it to it’s actual data type, be sure you cast it to the right type to prevent stack-traces. You can get the enumId from a AnyType-enum by using the DictEnum::value2id(AnyType _value) -function. Then you can compare it with the enumnum(EnumType) to check if it is the right type.