What is Event Examples in D365 F&O
Table of Content:
What is Event handlers?
An event handler is a way for you to write or copy code to an element that runs when a certain event occurs, such as when a field is modified or a record is deleted. Some elements, like tables and forms, contain an Events node in the designer window that, when expanded, lists all the events that are associated with that element. If you need to add supplementary behavior that doesn't currently exist in an element, you should create an extension of that element, and then add an event handler to the extended element.
The following are methods for event handlers that are pulled from the CustTable
table. These methods can be copied and added to your extended element or class by right-clicking the event in the element designer window and selecting Copy event handler method.
Objects That Can Use Chain Of Command
Event handlers Examples
OnDeleted
event - This is a post-event handler that triggers when a record is deleted in the table. You could use this, for example, to display an Infolog message after a record is deleted./// /// /// /// /// [DataEventHandler(tableStr(CustTable), DataEventType::Deleted)] public static void CustTable_onDeleted(Common sender, DataEventArgs e) { }OnInserting
event - This is triggered when data is being inserted. For example, this could trigger when you add a new customer to finance and operations apps./// /// /// /// /// [DataEventHandler(tableStr(CustTable), DataEventType::Inserting)] public static void CustTable_onInserting(Common sender, DataEventArgs e) { }OnValidatedWrite
event - This is a post-event handler that triggers after data is entered. This is used to validate data that is being written to a page, such as ensuring that a customer is at least 18 years old by verifying a birth date./// /// /// /// /// [DataEventHandler(tableStr(CustTable), DataEventType::ValidatedWrite)] public static void CustTable_onValidatedWrite(Common sender, DataEventArgs e) { }