Number Sequence in Dynamics AX 2012 – Part 2
Create a Number Sequence from Scratch
Now we will implement a Number Sequence in an existing Form.
Objective
Create a Number Sequence HCMEmploymentLeave form.
Solution
We will take a few steps to achieve this.
In this example, we will create a Number Sequence from scratch for Employment leave. The Form and the table which we are going to use are “HCMEmploymentLeave” and “HCMEmploymentLeave”. Please note that you might see few fields
Step 1: Create an EDT of type string
Here we have create EDT with name HCMEmploymentLeaveId
Step 2: Drop the EDT in the field of table you plan to make sequence number for
Step 3: Add the code in the NumberSeqModule###
Step 4: Create a method in HRMParameterTable to return the Number Sequence Reference
Step 5: Declare NumberSeqFormHandler in the Form “HCMEmploymentLeave”
Step 6: Add the NumberSeqFormHandler method to the form
Step 7: Add create(), delete(), write(), ActiveLink() and validateWrite() methods to the methods of Data Source of the Form
HCMEmploymentLeave: Create()
public void create(boolean _append = false) { element.numberSeqFormHandler().formMethodDataSourceCreatePre(); super(_append); element.numberSeqFormHandler().formMethodDataSourceCreate(); }
HCMEmploymentLeave: delete()
public void delete() { element.numberSeqFormHandler().formMethodDataSourceDelete(); super(); }
HCMEmploymentLeave: write()
public void write() { super(); element.numberSeqFormHandler().formMethodDataSourceWrite(); }
HCMEmploymentLeave: close()
public void close () { if (numberSeqFormHandler) { numberSeqFormHandler.formMethodClose(); } super(); }
Step 8: Create a Job with following code and Run
static void NumberSeqLoadAll (Args _args) { NumberSeqApplicationModule::loadAll(); }
Step 8: Create a Job as below and Run
Step 9: Check and verify that the Number Sequence have been created for the reference
The process is same as described in the section Create a new Number Sequence.
Result
Implement the Number Sequence and see it in action