About Events and Event Handlers
When operations are executed on the Max platform, events are fired. These events differ based on the originating operation and the moment and context in which they are fired. You can create event handlers that fire when specific events are triggered to add, extend, or modify the functionality of the operation that triggers the events. There are two types of events, Operation Events and CUD Events.
Operation Events are fired when REST service or generic operations are executed. For each REST service or generic operation execution, a Before Operation event record is generated before operation execution, and an After Operation event record is generated after execution is complete.
CUD Events are fired when create/update/delete template operations are executed. When object records are created, updated, or deleted, a Before CUD event is triggered before the template operation is executed, and an After CUD event record is triggered after execution is complete. CUD Event and Operation Event records call their event handlers at different points in the transaction lifecycle, and pass parameters to the handlers to trigger further actions.
For example, when an Appointment object is created, the Create Template operation is executed, and Before Create and After Create events are fired. If the same record is later updated, Before Update and After Update events are fired. Similarly, Before Delete and After Delete events are fired when objects are deleted.
Before CUD events are fired before the operation is executed within the transaction to create, update, or delete a record. All parameters received by the CUD operation are passed to the relevant event handlers, and an additional parameter, iop_result, is passed for update and delete operations. This parameter is a hash that contains the actual record to be updated or deleted, and you must get the object key inside the hash. The parameter’s extraction is solved during event handler implementation as long as you write classes that inherit from the appropriate helper class, so that the affected records can be obtained by accessing the affectedMaxObject property.
After CUD events are generated after the commit for the transaction where a record is created, updated or deleted. This means that event handlers implemented for After CUD events must create transactions for which the records received as parameters are already committed to the database.
For more information:
Was this helpful?