Tuesday, 24 July 2012

Number sequence Implementation in Dynamics AX 2012

In Dynamics ax 2012, there are number of enhancement in number sequence framework and implementation as well, here are the simple steps that needs to follow to implement it.
1 Created a new EDT
2. Added the code in the class NumberSeqModuleSalesOrder method loadModule() , see existing implementations in the loadModule method for reference.
3. Created a new method in the table SalesParameters to access the next sequence number. The method should return your module enum and also one method for each datatype (check existing implementations in the SalesParameters table)
4. Write a job that initiates your class and call the loadModule method

static void jobName(Args _args)
      NumberSeqModuleSalesOrder  NumberSeqModuleSalesOrder = new NumberSeqModuleSalesOrder();


Above 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 sequnce loads while restarting the Dynamic AX. In AX 2012 all the number seuqnce 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.

For implementation of new number sequence in new Module you should create a class following below steps

1.Add the NumberSeqModule enum with your module.
2. Create a new class for your numSeq which extends NumberSeqApplicationModule class with the standard methods (check existing implementation for any module like Project)
3. In the loadModule you put all your datatypes for which you want to create number sequence, again follow any existing class for the implementation.
4. rest of the steps are same that you need to create a job to load the new number sequences.

Thursday, 5 July 2012

Adding Find\Filter functionality on Display method AX 2009

Override Context method of Form control which is using display method and provide code for filter. E.g I have done below for PhysicalInvent field of InventOnHandItem form.

void context()
int                     selectedMenu;
real                    test;
formrun             fr;
Args                   ag;
Itemname           strtext;
querybuilddataSource    qb1;
queryrun             qr;
query                   q;
PopupMenu        menu = new PopupMenu(element.hWnd());
int                       a = menu.insertItem('Find');
int                       b = menu.insertItem('Filter');
int                       c = menu.insertItem('Remove Filter');

selectedMenu = menu.draw();
switch (selectedMenu)
case -1:
case a:
ag = new args('SysformSearch');
fr = new formrun(ag);
strtext = fr.design().controlName('FindEdit').valueStr();
q = inventSum_Ds.query();
qb1 =q.dataSourceTable(tablenum(InventSum));
case b:
case c :