Trigger
- is a procedural code that is automatically executed in response to certain event in database
- custom code that fires when a record is created, updated or deleted.
What happens when you hit "Save"?
1. Old values are written
2. System Validation Rules
3. Apex (before) Triggers
4. Custom Validation Rules
5. Record Saved to DB (Not Saved)
6. Record reloaded from DB
7. Apex (after) Trigger
8. Assignment Rules
9. Auto-Response Rules
10. Workflow Rules
11. Escalation Rules
12 Rollup Summary Formulas updated
13 Database Commit
14. Post commit logic(Sending Emails etc)
Cannot control the logic within each group.
Write triggers only when everything fails to solve the issues.
Big replacement for triggers are -
Workflow rules.
It can
- Update field
- Assign task
- Send Emails
- Send outbound messages (Integration)
Workflow rules can't -
1. Create other records - Automatically create other records
2. Complex calculations - Calculate total revenue from child accounts
3. Automatically submit records for approval.
4. Delete records



