Developing Plug-in Event Handlers
๐ฏ Goalโ
This tutorial shows you how to develop event handlers in your own plug-in, enabling you to intercept and respond to data model events throughout the iDempiere system.
What is an Event Handler?โ
An event handler is a component that listens to and responds to events triggered by changes to data models (tables) in iDempiere. Event handlers are executed whenever records are created, updated, or deleted, regardless of how the change was initiated.
Event handlers are commonly used to:
- Validate data across all entry points (UI, REST API, processes, imports)
- Enforce business rules that must apply system-wide
- Trigger automated actions when data changes (e.g., send notifications, update related records)
- Maintain data integrity through cross-table validations
- Audit and log specific operations
- Integrate with external systems when data changes
For example, when a Sales Order is completed, an event handler can automatically create a shipment, send a notification email, or update inventory levels.
Event Handlers vs Calloutsโ
| Feature | Event Handler | Callout |
|---|---|---|
| Scope | All operations (UI, API, processes, imports) | UI and CSV Importer only |
| Execution Point | Before/after database operations | During field value changes in UI |
| Use Case | System-wide business rules and validations | UI-specific field interactions |
Use event handlers when you need logic that applies regardless of how data is entered or modified. Use callouts for UI-specific interactions like auto-filling fields or showing immediate feedback to users.
โ Prerequisitesโ
Before starting, review:
You should already know how to create a plug-in, as this guide will not cover that in detail.