Creating Event Handlers
You can create custom Event Handlers as your needs dictate. To implement an Event Handler, you first create a Source record to implement the needed logic, and then create an Operation record that uses the newly created Source record. After that, you create an Event Handler record and run the Synchronize option to complete the implementation. For more information, see Working With Event Handlers in Max for Developers.
Alternatively, to save time and effort, you can use Max Designer to quickly create Batch and Before Event Handlers together with the necessary Source Operation, and Event Handler records.
To create Event Handlers:
1. In Max Designer, on the Developer Tools () launchpad menu, click Object Designer, and then in the top left corner, search for and select the Object for which you want to create a new Event Handler.
2. In the left pane, click Event Handlers, and then in the right pane, in the Create New Event Handler area, implement customization logic either for the currently selected Object, or for handling records of Objects related to the currently selected Object.
In the code editor, the following specific field values are predefined when records are saved. The values are placeholders, and you must customize the code with the appropriate logic.
Record
Field
Value
Event Handler
Name
Custom Event Handler for [Object Name]
Operation
The newly created Operation record
Trigger
Before
Batch checkbox
Selected
Originators
Create, Update, and Delete operations of the selected Object
Operation
Name
Operation of Custom Event Handler for [Object Name]
Computer Language
Groovy
Class Name
<package_name>.<class_name> (generated from Groovy code)
Method Name
execute
Sources
The newly created Source record
Source
Name
<package_name>.<class_name> (generated from Groovy code)
Operations
The newly created Operation record
Code
The Groovy code in the code editor
When a specific field in the currently selected Object is updated, the following logic implements the update of a calculated field in a related Object.
// By checking whether a field of recordOfCurrentObject has been changed,
// to update records of related object which has a calculated field that reads the field values of recordOfCurrentObject.
// - field_full_identifier: the field's full identifier belonging to the object of recordOfCurrentObject
// - property_to_read_related_records: the property name to read records from a relationship
if (recordOfCurrentObject.isFieldChanged("field_full_identifier")) {
recordOfCurrentObject.property_to_read_related_records.each { it.setDirty() }
}
For more information:
Was this helpful?