Sunday, 16 June 2013

Event handler for a clean world [AX 2012]

Eventing has been covered in many blogs and Microsoft has documented it pretty well.

I thought I should touch on it a little bit today to bring it back in our conversation.

Below is an example of eventing that used. Say you wanted to extend the PurchLine table modifiedField method. In the old days you would modify the method directly. Making it dirty. If you had another ISV making a modification, they would do the same. Meaning, someone has to merge code.

Have a look at the example below. PMF stands for Process Manufacturing which used to be separate from the foundation model and similarly BR stands for Brazil which is a country specific module. Both are done using event triggers. See the property they are called Post the method. Pointing to a class.

Eventing2013-06-14_1630

The end result is”No code merging” at all.

The only reason I would modify the method directly is if you needed to put your code in the middle of a long process.

Long story short. Use eventing for a cleaner environment. Write your code in a nice organized (modular) methods. Rather than writing huge code blocks that do 100 different things.

No comments: