Table Extension Event Example in D365 F&O with Example
Table of Content:
Table Event Handler in d365
In Microsoft Dynamics 365, a table event handler is a type of event handler that is used to handle events that are raised for tables in the application database. Table event handlers are used to add or modify the functionality of the standard application, without modifying the original code of the application.
Here is an example of how to create a table event handler in D365:
- Open the AOT (Application Object Tree) in Dynamics 365.
- Expand the Data Model node, and then select Tables and right click then open design.
- Expand the table see Event the Right-click on the table for which you want to create an event handler and select "Copy Event Handler Method".
- In the Event Handler dialog box, select the event you want to handle (for example, OnInsert).
- In the Class Name field, enter a name for the new class that will handle the event.
- Click the Add button to create the new class.
- In the class editor window, write the code that will handle the event.
Here is an example of code for a table event handler that handles the OnInsert event:
class MyTableEventHandler { [DataEventHandler(tableStr(MyTable), DataEventType::OnInsert)] public static void MyTable_OnInsert(Common sender, DataEventArgs e) { MyTable myTable = sender as MyTable; if (myTable) { // Do something when a new record is inserted in MyTable } } }
In this example, the MyTable_OnInsert
method is called when a new record is inserted in the MyTable table. The method receives two parameters: the sender
object (which is the table that raised the event) and the event arguments
(which contain information about the event).
Table event handlers are a powerful tool for customizing the functionality of Dynamics 365 without modifying the original code of the application. They allow you to add new features, customize the behavior of existing features, or integrate with external systems.
Screenshot
You can see a table structure and events present inside it. |
|
Note: Events are exposed on the designer on different element and sub-element types, like table events, form events, form data source events, form control events, and others. Open the context menu of an event node to interact with events: |
|