Monday, 23 March 2015

Simple Steps To Create Number Sequence In Ax2012

Number Sequence Creation:
Here I want to design a form named FirstForm with DataSource FirstTable
I want to create sequence  like "AX00001---------AX99999".

Step 1
Create an EDT - String Type
So, I created an EDT named "AXSeqEDT" with label "AX Seq"
Drag into Table(FirstTable)àFields

Step 2
Now create a new Number Sequence
Path for creating num Sequence is
"Module:: Organization administration.......Common.........Number sequences......Number sequences"
Click on New(Number Sequence)
Now number Sequence form will be opened----That contains 4 sections.
Section 1.Identification.....Specify the NumberSeqCode and Name
Section 2.Scope Parameters... Select the Scope from the Dropdown
Section 3.Segments.... Add the constant and alphanumeric (by clicking the add button and selecting from drop down)
Section 4 .General.....Checkmark for continous and Specify the "smallest and largest and Next" Fields
Now Save Ur Settings

Step 3
Now add the Respective manual-code to class - NumberSeqModuleURMODULE
And Table - URMODULEParameters.
So I am creating number sequence based on HRM Module.....So iam usingclassNumberSeqModuleHRM and TableHRMParameters
Now go to AOT---Classes-NumberSeqModuleHRM---loadModule()
Add the code here...
Note::Here we can add the code seeing the existing implementation
The Added Code is::
/* setup discussion number sequence - it is global */
Now Goto AOT---Tables---HRMParameters---methods-----click on new method

Add the code In the New method
Note::Here we can add the code seeing the existing implementation

The Added Code is
static client server NumberSequenceReference numRefAXSeqEDT()

Step 4
In order to add our newly created number sequence reference to our Module write the following Job and Execute it
Below job is important to run because without it your new number sequence will not be available to number sequence form under Parameters. This is the change in behavior from AX 2009 where all new number sequence loads while restarting the Dynamic AX. In AX 2012 all the number sequence created to system while installation, so restarting the AOS wont effect in loading the new number sequence, that is why it is important to run the job to load new number sequences.
The Code added in The Job is
static void jobName(Args _args)
    NumberSeqModuleHRM  NumberSeqModuleHRM = newNumberSeqModuleHRM();

Step 5
Organization Administration >> CommonForms >> Numbersequences>>Numbersequences>> Generate >> run the wizard.

Step 6
Now we have to check the number sequence  is correctly working  for that write a job:

static void number(Args _args)
    NumberSeq  numberSeq;
    CarId num;
    numberSeq = NumberSeq::newGetNum(ProjParameters::numRefcarId());
    num = numberSeq.num();

Step 7
Now add the Code in Create method of Forms Datasource methods
Goto-AOT-Forms-FirstForm-Datasources-FirstTable-Methods-Override method(Create)
public void create(boolean _append = false)
    FirstTable.AXSeqEDT = NumberSeq::newGetNum(HRMParameters::numRefAXSeqEDT(),true).num();

Step 8
Now save all your settings.....Now Open our form-FirstForm

Another tutorial