Number sequences

Number sequences

Number sequences in Axapta are a mechanism
for generating unique numbers. These are generally used as a unique Id to
identify a table record.

Every number sequence is
linked to an ExtendedDataType inside Axapta. Therefore you will need to create
separate datatypes for each number sequence which will be created.


1 Adding a number sequence

1.1 Add an element to the NumberSeqModule base enum

1.2 Extend the NumberSeqReference class

1.3 Create a parameters table and form

2 Calling a number sequence

Adding a number sequence

You may wish to use one or
more new number sequences when you create your own module inside Axapta.

The steps to add your own
number sequence to Axapta are fairly straight-forward, but lengthy. The
following description is based on the Axapta best-practice methodologies.

For this example, we will
add one new number sequence called NSId for a new module called NS. This
assumes that an ExtendedDataType called NSId already exists.

If not using an existing
extended datatype, create a new string EDT, which extends datatype ‘num’. Note
that in Ax 3.0 this num is a string field, length of 20.

Add an element to the NumberSeqModule base enum

One element should be added
to the enum for your module, irrespective of the number of actual number
sequences which will be created.

Therefore we modify the
NumberSeqModule enum and add the element NS.

Extend the NumberSeqReference class

Create a new sub-class of
NumberSeqReference and implement the numberSeqModule() and loadModule()
methods. Use an existing sub-class as a template to assist with this. This is
shown below.

public class NumberSeqReference_NS extends NumberSeqReference




Detailed description of how to setup
references for number sequences can

be found i method loadModule() on the
‘father’ class: numberSeqReference.


protected void loadModule()


NumberSequenceReference numRef;


// Setup Job TransId

numRef.dataTypeId =

numRef.referenceHelp =
“Some description

numref.WizardContinuous =

numRef.WizardManual =

numRef.WizardAllowChangeDown =

numRef.WizardAllowChangeUp =

numRef.sortField = 1;



public static NumberSeqModule numberSeqModule()


return NumberSeqModule::NS;


In addition, you must
modify the construct() and moduleList() methods on NumberSeqReference itself to
add references to your new module class. Note the sections of code surrounded
by //— NS Begin and //— NS End

static public container


container moduleList;


moduleList += NumberSeqReference_Bank::numberSeqModule();

moduleList += NumberSeqReference_BOM::numberSeqModule();

moduleList += NumberSeqReference_Customer::numberSeqModule();

moduleList += NumberSeqReference_Document::numberSeqModule();

moduleList += NumberSeqReference_ForeignTrade::numberSeqModule();

moduleList += NumberSeqReference_General::numberSeqModule();

moduleList += NumberSeqReference_Inventory::numberSeqModule();

moduleList += NumberSeqReference_Ledger::numberSeqModule();

moduleList += NumberSeqReference_Location::numberSeqModule();

moduleList += NumberSeqReference_MasterPlanning::numberSeqModule();

moduleList += NumberSeqReference_Production::numberSeqModule();

moduleList += NumberSeqReference_Project::numberSeqModule();

moduleList += NumberSeqReference_PurchaseOrder::numberSeqModule();

moduleList += NumberSeqReference_Route::numberSeqModule();

moduleList += NumberSeqReference_SalesOrder::numberSeqModule();

moduleList += NumberSeqReference_Tax::numberSeqModule();

moduleList += NumberSeqReference_Vendor::numberSeqModule();

moduleList += NumberSeqReference_Internet::numberSeqModule();

moduleList += NumberSeqReference_Asset::numberSeqModule();

//— HRM Begin

moduleList += NumberSeqReference_HRM::numberSeqModule();

moduleList += NumberSeqReference_KnowledgeCollector::numberSeqModule();

moduleList += NumberSeqReference_VirtualNetwork::numberSeqModule();

//— HRM End

//— CRM Begin

moduleList += NumberSeqReference_CRM::numberSeqModule();

//— CRM End

//— SFC Begin

moduleList += NumberSeqReference_JobManager::numberSeqModule();

//— SFC End

//— NS Begin

moduleList += NumberSeqReference_NS::numberSeqModule();

//— NS End

return moduleList;


public static numberSeqReference construct(NumberSeqModule _module)


switch (_module)


case (NumberSeqReference_Ledger::numberSeqModule()) : return new NumberSeqReference_Ledger(_module);

case (NumberSeqReference_Tax::numberSeqModule()) : return new NumberSeqReference_Tax(_module);

case (NumberSeqReference_Bank::numberSeqModule()) : return new NumberSeqReference_Bank(_module);

case (NumberSeqReference_SalesOrder::numberSeqModule()) : return new NumberSeqReference_SalesOrder(_module);

case (NumberSeqReference_ForeignTrade::numberSeqModule()) : return new NumberSeqReference_ForeignTrade(_module);

case (NumberSeqReference_Customer::numberSeqModule()) : return new NumberSeqReference_Customer(_module);

case (NumberSeqReference_PurchaseOrder::numberSeqModule())
return new NumberSeqReference_PurchaseOrder(_module);

case (NumberSeqReference_Vendor::numberSeqModule()) : return new NumberSeqReference_Vendor(_module);

case (NumberSeqReference_Inventory::numberSeqModule()) : return new NumberSeqReference_Inventory(_module);

case (NumberSeqReference_BOM::numberSeqModule()) : return new NumberSeqReference_BOM(_module);

case (NumberSeqReference_Route::numberSeqModule()) : return new NumberSeqReference_Route(_module);

case (NumberSeqReference_Production::numberSeqModule()) : return new NumberSeqReference_Production(_module);

case (NumberSeqReference_MasterPlanning::numberSeqModule()) :
return new NumberSeqReference_MasterPlanning(_module);

case (NumberSeqReference_Project::numberSeqModule()) : return new NumberSeqReference_Project(_module);

case (NumberSeqReference_Location::numberSeqModule()) : return new NumberSeqReference_Location(_module);

case (NumberSeqReference_Document::numberSeqModule()) : return new NumberSeqReference_Document(_module);

case (NumberSeqReference_General::numberSeqModule()) : return new NumberSeqReference_General(_module);

case (NumberSeqReference_Internet::numberSeqModule()) : return new NumberSeqReference_Internet(_module);

case (NumberSeqReference_Asset::numberSeqModule()) : return new NumberSeqReference_Asset(_module);

CC begin

case (NumberSeqReference_HRM::numberSeqModule()) : return new NumberSeqReference_HRM(_module);

case (NumberSeqReference_VirtualNetwork::numberSeqModule()) : return new NumberSeqReference_VirtualNetwork(_module);

case (NumberSeqReference_KnowledgeCollector::numberSeqModule())
return new NumberSeqReference_KnowledgeCollector(_module);

CC end

Shop Floor Control begin

case (NumberSeqReference_JobManager::numberSeqModule()) : return new NumberSeqReference_JobManager(_module);

Shop Floor Control end

CRM addition begin

case (NumberSeqReference_CRM::numberSeqModule()) : return new NumberSeqReference_CRM(_module);

CRM addition end

Product Builder addition begin

case (NumberSeqReference_PBA::numberSeqModule()) : return new NumberSeqReference_PBA(_module);

Product Builder addition end

NS begin

case (NumberSeqReference_NS::numberSeqModule()) : return new NumberSeqReference_NS(_module);

NS end


throw error(strFmt(


Create a parameters table and form

You should create a parameters table and form for
your new module. The easiest way is generally to duplicate an existing
Parameters table and modify it as required.

The important elements on
the new parameter table are the numberSeqModule() and numberSeqReference()

client server static
NumberSeqModule numberSeqModule()


return NumberSeqReference_NS::numberSeqModule();


client server static
NumberSeqReference numberSeqReference()


return NumberSeqReference::construct(NSParameters::numberSeqModule());


In the parameters form, you
must ensure that the code in the numberSeqPreInit(), numberSeqPostInit() and
NumberSequenceType.executeQuery() methods correctly reflect your new number
sequence elements.

Calling a number sequence

The following code gets a
number from the number sequence setting for EDT CustAccount

static void Job1(Args _args)


ExtendedTypeId id = TypeID2ExtendedTypeId(TypeId(CustAccount));

NumberSeq num = NumberSeq::newGetNum(NumberSequenceReference::find(id));





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

%d bloggers like this: