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.
No comments:
Post a Comment