Overview
Number sequencing is an essential feature in an Enterprise Resource Planning (ERP) system. Microsoft Dynamics
® AX employs a number sequence framework to generate alphanumeric number sequences. The primary purpose of the number sequence framework is to provide unique, user-friendly identifiers while maintaining a continuous or noncontinuous alphanumeric sequence.
There are two main concepts in Number Sequence Framework.
·
Segments:
Is a data entity such as legal entity, operating unit, or fiscal calendar period that can be used to define a number sequence. In the enhanced number sequence framework, a number sequence can have more than one segment.
e.g) J-20-Jan11 is a combination of multiple segments.
·
Scope:
Is a valid combination of segments used for a specific transaction or master data entity.
e.g.) Company + Fiscal Calender Period.
Steps
· Create an EDT of type String. In this Example I will use CustGroupId.
· Open the NumberSeqModuleCustomer class in the Application Object Tree (AOT), and add the following code to the bottom of the loadModule() method:
datatype.parmDatatypeId (extendedTypeNum (CustGroupId));
datatype.parmReferenceHelp ("Customer group ID");
datatype.parmWizardIsContinuous (false);
datatype.parmWizardIsManual (NoYes::No);
datatype.parmWizardIsChangeDownAllowed (NoYes::Yes);
datatype.parmWizardIsChangeUpAllowed (NoYes::Yes);
datatype.parmWizardHighest (999);
datatype.parmSortField (20);
datatype.addParameterType (NumberSeqParameterType::DataArea,true, false);
this. Create(datatype);
· Create a new job with the following code and run it:
Static void NumberSeqLoadAll (Args _args)
{
NumberSeqApplicationModule::loadAll();
}
· In the Organization administration | Common | Number sequences | Number sequences generate number sequence. Delete everything apart from the lines where Area is Accounts receivable and Reference is Customer group.
· Locate the
CustParameters table in the AOT and create the following method:
Public server static NumberSequenceReference numRefCustGroupId ()
{
return NumberSeqReference::findReference ( extendedTypeNum(CustGroupId));
}
· In the AOT, open the
CustGroup form and add the following code to its class declaration:
NumberSeqFormHandler numberSeqFormHandler;
· Create a new method called
numberSeqFormHandler() in the same form:
Public NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler = NumberSeqFormHandler::new Form(
CustParameters::numRefCustGroupId().NumberSequenceId,
element,
CustGroup_ds,
fieldNum(CustGroup,CustGroup));
}
return numberSeqFormHandler;
}
· Override CustGroup data source's
create() method with the following code:
Public void create (Boolean _append = false)
{
element. NumberSeqFormHandler ().formMethodDatasourceCreatePre ();
super (_append);
element. NumberSeqFormHandler ( ).formMethodDatasourceCreate ();
}
· Override its
delete() method with the following code:
Public void delete ()
{
ttsBegin;
element.numberSeqFormHandler().formMethodDatasourceDelete ();
super ();
ttsCommit;
}
· override its
write () method with the following code:
Public void write()
{
ttsBegin;
super();
element.numberSeqFormHandler().formMethodData sourceWrite();
ttsCommit;
}
· Override its
validateWrite() method with the following code:
Public boolean validateWrite ()
{
boolean ret;
ret = super();
ret = element.numberSeqFormHandler( ).formMethodDatasourceValidateWrite(ret)&& ret;
return ret;
}
· Override its
LinkActive() method with the following code:
Public void linkActive()
{
element.numberSeqFormHandler ( ).formMethodDatasourceLinkActive();
super();
}
· Finally, override the form's
close() method with the following code:
Public void close ()
{
if (numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose ();
}
super();
}
· Open
Accounts receivable | Setup | Customers | Customer groups to test and create new entries.