Days 1 and 2 were related to creating the structure of your CRM, developing modules, setting up fields, and determining how your data relates. On Day 3, you will see
Days 1 and 2 were related to creating the structure of your CRM, developing modules, setting up fields, and determining how your data relates. On Day 3, you will see how the CRM's advanced structure, which you have built previously, starts doing the work for you. Day 3 explores automation and control in SuiteCRM in much more detail: enabling SuiteCRM to respond to what happens inside it, implement tasks based on a schedule, and communicate using the tools around it.
At the core of it is our SuiteCRM Logic Hooks โ a method through which you can deploy your own business logic to record events without disturbing the core files. Along with that, you will also learn how you can set up scheduled tasks that operate in the background and entry points that allow external systems to communicate directly with your CRM. And ultimately, to sync it all, we will give you a practical QA workflow so that you can test each modification with total confidence before it is live.
Logic Hooks
Logic Hooks are PHP callbacks that fire automatically when specific events occur on a Bean (record). They are the primary way to add business logic without modifying core SuiteCRM files.
Every hook receives three standard parameters: $bean (the record object), $event (the hook name string), and $args (an associative array with context-specific data).
Module-Level Hook Events
| After a record is loaded from the DB | When It Fires |
|---|---|
| before_save | Before a record is saved (new or update) |
| after_save | After a record is saved successfully |
| before_delete | Before soft-delete flag is set |
| after_delete | After soft-delete completes |
| after_retrieve | After a record is loaded from DB |
| before_relationship_add | Before a relationship link is created |
| after_relationship_add | After a relationship link is created |
| before_relationship_delete | Before a relationship link is removed |
| after_relationship_delete | After a relationship link is removed |
Registration Format
// FILE: custom/Extension/modules/Accounts/Ext/LogicHooks/ow_before_save.php
$hook_version = 1;
$hook_array = [];
$hook_array['before_save'][] = [
1, // Priority (lower = runs first)
'My Hook Description', // Description string
'custom/modules/Accounts/OWBeforeSave.php', // File path
'OWBeforeSave', // Class name
'execute', // Method name
];
Hook Class Example
// custom/modules/Accounts/OWBeforeSave.php
class OWBeforeSave {
public function execute($bean, $event, $args) {
if (empty($bean->id)) {
// New record โ set default priority
$bean->ow_priority_c = 'medium';
}
// Validate required custom field
if (empty($bean->ow_client_code_c)) {
throw new Exception('Client Code is required.');
}
Scheduled Tasks (Cron Jobs)
Scheduled Tasks run automated PHP functions on a timer. SuiteCRM's job scheduler requires a single cron entry that delegates to SuiteCRM's internal scheduler.
Cron Entry
* * * * * php /var/www/html/crm/cron.php
Registering a Scheduled Task
// FILE: custom/Extension/modules/Schedulers/Ext/ScheduledTasks/sendFollowUpEmails.php
function sendFollowUpEmails() {
// Your logic here
$db = DBManagerFactory::getInstance();
// ... query and process records ...
return true; // Return true on success
}
$job_strings[] = 'sendFollowUpEmails';
Entry Points
Entry Points are custom HTTP endpoints that can be called from outside SuiteCRM (webhooks, external APIs, etc.). They bypass the normal module/action routing.
Registry File
// FILE: custom/Extension/application/Ext/EntryPointRegistry/customLeadSync.php
$entry_point_registry['customLeadSync'] = [
'file' => 'custom/customLeadSync.php',
'auth' => true, // Require SuiteCRM login session
];
Always set auth: true on entry points unless you explicitly need public access (e.g., an incoming webhook from an external service). Unauthenticated endpoints are a security risk.
QA Workflow โ What to Test After Every Change
- Run Quick Repair & Rebuild after any metadata/hook change.
- Verify the hook fires on both new record creation and record update.
- Check suitecrm.log for errors after running the hook.
- Test with missing required fields to confirm validation fires correctly.
- For scheduled tasks, manually trigger via Admin โ Schedulers to verify before relying on cron.
- For entry points, test with both authenticated and unauthenticated requests.
Conclusion
Up until now, you might have gotten the complete picture of how SuiteCRM can be extended in the perfect way, more safely, cleanly, and without any shortcuts that can prove to be costly later on. SuiteCRM Logic Hooks provide you with accurate control over what actually happens when a record is updated, created, or deleted. Scheduled tasks help you manage routine work in the background. Entry points provide space to carry out external integrations while ensuring security remains intact. Ultimately, the QA workflow ensures that none of these Logic Hooks get deployed without testing.
Day 4 takes a step further, and instead of creating from scratch, you will understand how you can work quickly with OutRightโs own utility library and Flight internal tooling dashboard. You can consider it as enhancing your toolkit. It is the same Extension Framework you have been working with, with far less repetitive groundwork standing between you and the end result.
Respond to this article with emojis