By Abir HSAINI, Technical Services Engineer, 4D Inc.
4D 21 introduces a new way to handle database operations using ORDA events. This approach replaces traditional triggers and offers better control over data operations. ORDA events run automatically when data is created, modified, saved, or deleted, allowing developers to add validation, error handling, and business logic directly in their code.
Unlike old triggers that lock entire tables, ORDA events work on individual records and can run in parallel, improving performance in multi-user environments. This document explains how to use ORDA events effectively and provides guidance for migrating from classic 4D triggers to this modern approach.
With 4D 21, ORDA events provide a modern event-driven solution for handling database operations in an object-oriented manner, serving as a replacement for classic triggers. These events are implemented as data class functions and are automatically executed when records are created, updated, saved, or deleted, enabling precise control over data lifecycle actions.
Unlike classic triggers, which operate at the table level and can lock entire tables during execution, ORDA events work at the record level. This design enables multiple events to run in parallel on different records, improving multi-user performance. In addition, ORDA events centralize business logic within data classes, making validation rules and processing easier to maintain and more consistent.
ORDA automatically invokes these event functions in response to user actions or code operations, and they cannot be triggered manually. This guarantees consistent business logic across all access channels, including the user interface, REST APIs, and application code. With seven event types covering the full data lifecycle, ORDA events provide fine-grained control over save and drop operations and offer a robust, modern alternative to classic triggers.
Please read the full Tech Note as PDF
- 4D v21 or higher (ORDA events require v21+)
- Operating System: Windows, macOS, or Linux
- Minimum RAM: 4GB recommended
-
Open with 4D
- Launch 4D application
- File → Open → Select the project folder
- Or double-click the
.4DProjectfile
-
First Launch
- The database will open automatically
┌─────────────┐
│ Client │
├─────────────┤
│ ID │
│ Name │
│ Email │
│ Phone │
└─────────────┘
┌─────────────┐
│ Product │
├─────────────┤
│ ID │
│ Name │
│ Description │
│ Price │
│ Stock │
│ minimumStock│
└─────────────┘
┌─────────────┐
│ Order │
├─────────────┤
│ ID │
│ order_number│
│ Date_Order │
│ Date_Livr │
│ ID_Client │
│ Mode_Pmt │
│ Price │
│ Statut │
│ Description │
└─────────────┘
┌─────────────┐
│ OrderLine │
├─────────────┤
│ ID │
│ ID_Order │
│ ID_Product │
│ Quantity │
└─────────────┘
-
Open the Orders Form
- Click "New Order" button in the main window
-
Fill Order Details
- Order number: Auto-generated (CMD-YYYY-NNNN)
- Client: Select from dropdown
- Date Order: Auto-filled with today's date
- Delivery date: Optional
- Payment method: Select (Bank Transfer, Credit Card, etc.)
- Status: Auto-set to "In progress"
- Description: Optional comment
-
Add Products
- Click "Add new product" button
- A Form containig products is opened
- Select products
- Enter quantity
- Unit Price and Total calculate automatically
-
Save the Order
- Click the "Save" button
- System automatically:
- ✅ Validates stock availability
- ✅ Calculates total order price
- ✅ Decreases product stock
- ✅ Saves all changes