Working with numbersequences – new NumberSequence

May 5, 2009 1 comment

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:

1
2
3
4
5
6
7
8
9
numRef.DataTypeId = typeId2ExtendedTypeId(typeid(NewType));
numRef.ReferenceLabel = literalstr("@...");
numRef.ReferenceHelp = literalstr("@...");
numRef.WizardManual = NoYes::No;
numRef.WizardAllowChangeDown = NoYes::No;
numRef.WizardAllowChangeUp = NoYes::No;
numRef.SortField = #;
 
this.create(numRef);

5. Create a static method on the parameter table that will be used to retrieve the reference. These methods usually start with “numref”.
example:

1
2
3
4
static client server NumberSequenceReference  numRefNewType()
{
return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(NewType)));
}