How to: Modify the Return Value in an Post-Method Event Handler
Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
You can assign a static method to be an event handler that starts when a specific method on a class ends. This is called an after-method event handler, or a post-method event handler. In the AOT, you assign the event handler as a node under the method node. The CalledWhen property on the event handler node must be set to Post.
The post-method event handler can modify the return value of the completed method, before the return value is given to the method caller.
For background information about event handler nodes, see Event Handler Nodes in the AOT.
The AOT Elements
The following table displays the AOT elements that work together to process the event.
AOT element type |
X++ Code sample |
---|---|
Plain method: as a member of a class. |
|
Event handler: starts as a method of a class. |
|
Node relationship in the AOT. |
In the following image, notice that the numberOfExpectedAttendees method has a child node for the numberOfExpectedAttendeesEhAfter event handler. This node is created by dropping a static method AOT nodes for a method and its event handler By coincidence, the method node for the numberOfExpectedAttendeesEhAfter method is also on this same TestClass class. |
Job: to run the simple method. |
|
See also
How to: Modify Parameter Values in a Pre-Method Event Handler
Walkthrough: Subscribing an Event Handler to a Delegate in the AOT
Event Handler Nodes in the AOT
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.