Custom Events
Help & Basics
Published on 28.10.2025
With "Custom Events," you can execute JavaScript code that is automatically triggered by specific actions (e.g., when saving or deleting a record). This allows for the automation of processes, data validation, or integration with other systems.
Event Types (Triggers)
A distinction is made between client-side and server-side events.
Client-Side Events (in the user's browser)
These events have access to the data object, which contains the form data.
- When opening the "New" form (
before_create): Ideal for pre-filling fields with dynamic default values. - When opening the "Edit" form (
before_edit): Can be used to customize the user interface based on existing data. - Before deleting a record (
before_delete): For an additional, custom confirmation query. - Before opening the print view (
before_print): To manipulate thedataobject before sending it to the server for printing.
Server-Side Events (on the web server)
These events are executed in PHP and have direct access to the database.
- After creating a record (
after_create): Useful for sending notifications or creating follow-up tasks in other tables. - After saving a record (
after_update): To log changes or update dependent data. - After deleting a record (
after_delete): To clean up linked data in other tables. - When generating the print view (
on_print_record): To load additional data from the database and insert it into the print template.
Example Script: Set Default Value (before_create)
This client-side script sets the project_name field with a default value when a new record is created.
/**
* Event handler that runs before creating a new record.
* @param {object} data The form's data object. It can be modified here.
* @param {string} tableName The technical name of the table.
*/
function handleBeforeCreate(data, tableName) {
// Only run for a specific table
if (tableName === 'data_team_myteam_projects') {
// Format today's date (YYYY-MM)
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
// Set the default value for the 'project_name' field
data.project_name = `Project ${year}-${month}-`;
}
}