Tuesday, February 26, 2013

Enumerator and Iterator in Dynamics AX 2012



Difference between Enumerator and Iterator(use for list, Maps or Sets element’s traversing)

  • We can traverse our List, Map or Set collections by using either an enumerator or an iterator 
  • We can’t add/Delete elements in the List or Maps or Set using Enumerator class but we can do it via iterator class
  • It is a best practice to use the Enumerator class instead of the Iterator class, because enumerators are automatically created on the same tier as the map (when calling the List.getEnumerator method)
  • Enumerators require less code than iterators to initiate there instance, they perform slightly better.


For more information please refer to following link

Difference between Enumerator and Iterator in AX 2012

Automatic Events in Dynamics AX 2012



Introduction:

Automatic Events are those events that are triggered by the environment.

Types:

PreEvent:

The pre-event handlers are called before the execution of the designated method. Each of the pre-event handlers can access the original values of the parameters and modify them as required.

PostEvent:

Post-event handlers are called after the method call has ended. The post-event handlers can modify the return value of the called method.

Implementation:

Below is a sample project that shows how to implement Pre and Post Event Handlers in Dynamics Ax 2012.



This Project contains two Classes PrePostEvents and PrePostSample .  In PrePostSample Class there is a DemoMethod that contains Pre and Post Event handlers.

 


This Method takes an integer values passed from the Main method and has Pre and Post Event Handlers associated with it. The Properties Window of Pre and Post Event handler looks like this.


                            
                                          

The CalledWhen Property in the above Figure has the Value Pre Which Shows that it’s a PreEvent Handler.

 

                                    
Similarly, the CalledWhen Property shows that it is a PostEventHandler.


                                       

This method simply gets the _args passed by the Main Method.

 


This method gets the _args passed by the Main Method and replaces its value.

 


This method passes the value to the PreEvent Handler and the DemoMethod.
















Work Flow in Dynamics AX 2012

A Work Flow can be defined as a sequence of steps where each steps follows the precedent without any gap or delay.It can also be defined as a movement of tasks within a process. The Dynamics AX Work Flow infrastructure enables user configurable workflows in Dynamics Ax application modules with specific focus on tasks and approval workflows.

Please refer to the following article for complete understanding

Work Flow in Dynamics AX