Blog

Name is Anant Dubey and the intent to create this blog is to discuss the problems and issues that developer face in the dynamics AX development and to share the new things that come up with the new version of AX.

Monday, 6 January 2014

Number Sequence for existing module in ax 2012

 NumberSequence for  the Existing module
To create a numbersequence for  the Existing module.
Suppose in my HRM Module for the Employee Table I have to create the NumberSequence  (EmplTable).
I need to follow these steps to create the NumberSequence  .
 Go to the Classes -> NumberseqReference_HRM (Class) -> LoadMethod

In the load method you have to override the code , need to added the code to which field we are planning to add the code that it can be copied from the exisitng code and modfiy the EDT which we want to add   ( Here My EDT is EmplId)

Let us Assume (Existing Code )
numRef.DataTypeId = typeId2ExtendedTypeId(typeid(HRMApplicationId));


For The Empl Id We have to add the code means

numRef.DataTypeId = typeId2ExtendedTypeId(typeid(EmplId));


After completing the above procedure, we have to go to AOT -> Tables ->HRM Parameters -> Need to Override the code  in the method
Ex: The Overrided code is

static client server NumberSequenceReference numRefEmplId()
{
    return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(EmplId)));
}

Same code u copy as per u r requirement in there see the below screen shot

After the above step go to the Empl Form -> Form Level Methods u have to write the number sequence formhandler method have to create the code.
See the below figure.


Class declaration Code
IN the class declaration we have to write the code

NumberSeqFormHandler numberSeqFormHandler;

Numberseqformhandler Code
In the Numberseqformhandler write the below code

NumberSeqFormHandler numberSeqFormHandler()
{
    if (!numberSeqFormHandler)
    {
        numberSeqFormHandler = NumberSeqFormHandler::newForm(HRMParameters::numRefEmplId().NumberSequence,element, EmplTable_ds, fieldnum(EmplTable, EmplId));
    }
    return numberSeqFormHandler;
}

Then we have to Override  the DataSource Methods ( Create, Write ,Delete).

Write Method Code is
element.numberSeqFormHandler().formMethodDataSourceWrite(); ---- After Super

Create Method is
element.numberSeqFormHandler().formMethodDataSourceCreatePre(); - Before Super
super();
  element.numberSeqFormHandler().formMethodDataSourceCreate(); --- > After Super
Delete Method Code Is
element.numberSeqFormHandler().formMethodDataSourceDelete();---- After Super

After completing all the above steps.
Go -> HRM Module -> Setup -> Parameters -> Numbersequence


We have to add the reference for the EMP ID. To add the reference see the below screens .
Task1
Auto-generated document.



Task1 1
Form name: Human Resource parameters 2
Form name: Number sequences 3


1. Click Area Page node: Human Resources -> Setup -> Parameters.

Form name: Human Resource parameters
2. Switch to the Number sequences tab on the Human Resource parameters form.
3. Select the Number sequence code field.
4. Right-click the field to go to the main table.
Form name: Number sequences
5. Create a new record in the Number sequences form.
6. Change Number sequence code from 'Test_001' to 'Acco_42'.
7. Change Name from 'Testing' to 'Acco_42'.
8. Change Largest from '999999' to '99999999'.
9. Change Next from '4' to '1'.
10. Change Format from 'TST_######' to '########_042'.
11. Change In use from 'Yes' to 'No'.
12. Change Number sequence code from '' to 'USR_001'.
13. Change Name from '' to 'EmplTable'.
14. Change Format from '' to 'USR_######'.
15. Switch to the General tab on the Number sequences form.
16. Change Continuous from 'false' to 'true'.
17. Save the record in the Number sequences form.
18. Switch to the Overview tab on the Number sequences form.
19. Close the Number sequences form.
20. Change Number sequence code from 'Test_001' to 'USR_001'.
21. Save the record in the Human Resource parameters form.
22. Close the Human Resource parameters form.
23. Click the Microsoft Dynamics AX -> Tools -> Task Recorder menu item.