Overview
Hooks are the primary way to customize and extend Frappe Helpdesk without modifying core code. All hooks are defined inhelpdesk/hooks.py.
Available Hooks
App Configuration Hooks
Document Event Hooks
Execute custom code when documents are created, updated, or deleted.Example: Contact Override (from overrides/contact.py)
Example: Assignment Rule Validation (from extends/assignment_rule.py)
All Document Events
Permission Hooks
Customize document-level permissions.Scheduler Hooks
Run background tasks on a schedule.Scheduler Frequencies
all- Every 5 minuteshourly- Every hourdaily- Once per dayweekly- Once per weekmonthly- Once per monthcron- Custom cron expression
Example: Scheduled Task
Lifecycle Hooks
Run code at specific application lifecycle events.Example: After Install Hook
Override DocType Class
Replace standard Frappe DocTypes with custom implementations.Example: Custom Email Account (from overrides/email_account.py)
Website Route Hooks
Full-Text Search Hooks
Authentication Hooks
User Invitation Hooks
Ignore Links on Delete
Prevent deletion errors for specified DocTypes.Setup Wizard Hooks
Creating Custom Hooks
1. Global Document Hook
Apply to all documents:2. Custom Scheduler Event
3. Custom Fixture
Load data during tests:Best Practices
- Use Extends/Overrides: Place custom logic in
helpdesk/extends/orhelpdesk/overrides/ - Error Handling: Always use try-except in hooks to prevent breaking core functionality
- Permissions: Check permissions before executing sensitive operations
- Performance: Keep hooks lightweight; use background jobs for heavy operations
- Logging: Log errors with
frappe.log_error()for debugging - Testing: Test all custom hooks thoroughly
- Documentation: Document custom hooks for maintainability
- Transactions: Be careful with
frappe.db.commit()in hooks - Global Hooks: Use
*sparingly as it affects all documents - Versioning: Consider backward compatibility when modifying hooks