Friday 20 February 2015

Easy steps to create a number sequence in AX2012


Following are steps to create new NumberSequence in Ax 2012

1. Open the NumberSeqModuleXXX (XXX is for the module name e.g. NumberSeqModuleCustomer, NumberSeqModuleHRM etc) class in the Application Object Tree (AOT) and add the following code to the bottom of the loadModule() method:

datatype.parmDatatypeId(extendedTypeNum(YYYY)); //EDT used for number sequence

datatype.parmReferenceHelp("zzzzzzzzzzz");

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);

2.Create a new job with following code and run it:

static void NumberSeqLoadAll(Args _args)

{

NumberSeqApplicationModule::loadAll();

}

3.Run the number sequence wizard on the Organization

administration >Common >Number sequences > Number sequences > Generate and click on the Next button. Click on Details for more information. Delete the lines except the desired lines ( lines with your module and reference to your EDT). Click next and finish the wizard.

4.You will find the newly created numberSequence in the respective module's parameters form under numbersequence tab.
In the parameters table(zzzzParameters) in the AOT create the following method:

public server static NumberSequenceReference numRefYYYY()

{

return NumberSeqReference::findReference(extendedTypeNum(YYYY));

}

5.To use the number sequence refer to the following code :

public void initValue()

{

NumberSeq NumSeq;

;

super();

NumSeq = NumberSeq::newGetNum(zzzzParameters::numRefYYYY(),true);

//NumSeq.num(); this will create new numbers.

}

No comments: