Wednesday, March 21, 2012

Add new number sequence to existing AX module


To demonstrate this I have creted new form “Method table” which stores some of the characteristics of the items so I have added this Method table to Invent module.
Key for this table is “MethodId” & we are going to create number sequence for this table.

Look out the following steps to add number sequence for newly created form/table in existing module of AX 2009
1.   Create New EDT (Extened data type), i.e “MethodId” of type “str” size “20”.
2.   Find Number sequence class, in this case it is “NumberSeqReference_Inventory”.
3.   Find “LoadModule” method, add following code at the end of the method.






















4.  Create Following method to Form’s (The Form on which you have added data source) method.
NumberSeqFormHandler numberSeqFormHandler()
{
    if(!numberSeqFormHandler)
    {
        numberSeqFormHandler = NumberSeqFormHandler::newForm(ItemMethodTable::numRefMethodId().NumberSequence,
        element,ItemMethodTable.dataSource(),fieldnum(ItemMethodTable,MethodId));
    }
    return numberSeqFormHandler;
}


5.  Add folloing code to specified methods on the Form where you have added created table.
-          In Write Method
After super() write, element.numberSeqFormHandler().formMethodDataSourceWrite();
-          In Create Method
Before super() write,
       element.numberSeqFormHandler().formMethodDataSourceCreatePre();
After Super write,
element.numberSeqFormHandler().formMethodDataSourceCreate();
-           In delete Method
Before super() write,
      element.numberSeqFormHandler().formMethodDataSourceDelete();
           6. Now, you are done with code part, to give final touch go to, basic> Setup> Number Sequence and run       Wizard. To show up your created Number sequece in List.

That’s it. Enjoy DAXing J


No comments:

Post a Comment