Creating event handler methods
We have already created an event handler in the previous recipe.
So far, we have created an event handler for data events using the DataEventHandler
decoration and a delegate event handler using the SubscribesTo
decoration. We can also add handlers directly to any public method.
There are two types: a pre-event and a post-event handler. One example of where we may need to do this is the SalesTable.insert()
method. This doesn't call super()
, so we can't use a data event handler.
The actual insert occurs within the SalesTableType
class in the insert()
method. If you want access to the sales table record, you need to add the handler to the table as the record being inserted is a private variable to the class.
Event handlers like this are used to integrate specific solutions, so the handler will be in a class in the specific package.
Getting ready
We will just need a Dynamics 365 for Operations project and a class that requires the event handler open in the designer.