Number sequence creation in AX

Number sequences are an implicit part requirement for many of the customizations or implementations that happen in AX. Keeping this in mind here is a small piece of code that will help you in creating a new number sequence.
Let us start by taking an example in AR -> Setup -> Parameters. Assume you have to add a new number sequence reference called "My sequence". Here is a step by step process of what to do in order to create that number sequence.
  • Create a new EDT of type string and length say 20. Name this EDT as MySequenceEDT. Give label as "My sequence".
  • Travserse to class "NumberSeqReference_Customer". Remember that the base class for number sequence reference is "NumberSeqReference". Since we want to add a new number sequence in AR -> Parameters, we traverse to class that is mentioned above that is "NumberSeqReference_Customer"
  • Now open the method "loadModule"
  • Append the following piece of code to the method

        numRef.dataTypeId                       = typeId2ExtendedTypeId(typeid(MySequenceEDT)); //MySequenceEDT is a new EDT
        numRef.configurationKeyId            = configurationKeyNum(ledgerBasic); // This line of code is optional
        numRef.referenceHelp                   = "My number sequence";
        numRef.wizardContinuous              = false;
        numRef.wizardManual                    = NoYes::No;
        numRef.wizardAllowChangeDown    = NoYes::No;
        numRef.wizardAllowChangeUp        = NoYes::No;
        numRef.wizardHighest                    = 999999;
        numRef.sortField                            = 10; //Remember sort field should be one incremented from the reference above. If in the line above sortField is 9 then for our reference it is 10


  • Now traverse to the table "CustParameters"
  • Add following method to the CustParameters table

        static client server NumberSequenceReference  numRefSumit()
             return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(XpfLoggerMessage)));

There you go new number sequence is ready and can be seen in the AR -> Setup -> Parameters -> Number sequences tab

One thought on “Number sequence creation in AX

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s