Form Event Handlers in Microsoft Dynamics 365 for Operations (AX7)
In Microsoft Dynamics 365 for Operations (AX7), the preferred mechanism for reacting to the actions on a form is through eventing. Events on a form are located at the form level, on the datasources, on the fields within the datasources and on the controls within the form's design. The events available are very similar to the methods available on forms in previous versions of AX.
Below is an example of how to react to an event on a form containing the CustTable datasource:
1. Open the form designer for a form containing CustTable as a datasource.
2. Expand the CustTable datasource and find the Blocked field.
3. Under the Blocked field expand the Events node and find the OnModified event.
4. Right-click OnModified and choose Copy event handler method.
5. In the Solution Explorer right-click on your project name and choose Add > New Item
6. In the form that opens click Code and select Class
7. Name the class and click Add
8. In the code editor for the class between the curly brackets, right-click and choose Paste
***A method should be added that has a FormDataFieldEventHandler attribute
9. In the newly added method add the following code:
info("Blocked field modified");
10. Save and build your solution.
11. Run the form.
12. In the running form, click the Edit button and change the blocked field on one of the records and note the infolog comment towards the top of the form just below the action pane.