Logic Hooks are PHP functions in SuiteCRM that execute automatically when specific events occur — before a record saves, after a record saves, when a record is deleted, when a relationship changes, or when a user logs in. They are the code-level automation layer that gives developers programmatic control over CRM behavior.
Think of Logic Hooks as event listeners: you define which event to listen for (“before a Lead is saved”) and what action to take (“validate the phone number format” or “call an external API to enrich the lead data”). Logic Hooks can do anything PHP can do — query databases, call external APIs, modify records, create related records, send notifications, or trigger third-party services.

When an event occurs in SuiteCRM (a record is saved, deleted, or retrieved), the system checks for registered Logic Hooks. If hooks exist for that event, SuiteCRM executes them in the specified order.
Each hook receives a $bean parameter — a PHP object containing the record’s data. In a before_save hook, modifications to $bean persist when the record saves. In an after_save hook, the record is already in the database, so hooks perform follow-up actions like creating related records or calling APIs.
before_relationship_add / after_relationship_add — Fire when a relationship between two records is created. Use for enforcing relationship rules or synchronizing data.
SuiteCRM workflows (Advanced Open Workflow / AOW) are no-code automation configured through the admin interface. They handle standard automation — sending emails, updating fields, creating records. Logic Hooks are code-based and handle everything workflows can’t — external API calls, complex validation, conditional logic with multiple related records, and real-time data processing.
Use workflows when non-developers need to create and modify automation. Use Logic Hooks when the requirement exceeds what the workflow interface can express — complex conditions, external integrations, data validation, or performance-critical operations.
Most SuiteCRM deployments use both — workflows for standard automation and Logic Hooks for advanced scenarios.
Logic Hook files must be placed in the custom/ directory for upgrade-safe operation:
Hook definition files go in: custom/Extension/modules/{ModuleName}/Ext/LogicHooks/
Logic class files go in: custom/modules/{ModuleName}/
After adding or modifying hooks, run Admin → Repair → Quick Repair and Rebuild for SuiteCRM to recognize the changes. Never place custom code in the core modules/ directory — it will be overwritten during upgrades.
Auto-calculate a field. A before_save hook on Opportunities multiplies quantity × unit price to populate a total field — ensuring the calculation is always correct regardless of how the record is edited.
Validate data format. A before_save hook on Contacts validates email addresses using PHP’s filter_var function, blocking saves with invalid formats.
Notify external systems. An after_save hook on Opportunities detects when a deal stage changes to “Closed Won” and sends an HTTP POST to a Slack webhook, billing system, or ERP.
Prevent deletion. A before_delete hook on Accounts queries for open Cases — if any exist, it throws an exception that blocks the deletion and displays a user message.
Logic Hooks require PHP expertise and understanding of SuiteCRM’s internal architecture. Common mistakes include infinite loops (a hook that re-saves the same record, triggering itself), performance issues from slow API calls in before_save hooks, and permission conflicts from files placed in incorrect directories.
TechEsperto’s development team has built hundreds of Logic Hook implementations. As the Official SuiteCRM Professional Partner, we ensure every hook is upgrade-safe, performant, and maintainable. Contact us for custom development.