Apex Triggers

One trigger per object, logic in handlers, bulk-safe by default — the discipline that keeps automation debuggable.

Module overview 5 sections Free Updated 07 Jul 2025
Apex Triggers
Modules

One trigger per object, logic in handlers, bulk-safe by default — the discipline that keeps automation debuggable.

What you'll learn

The order of execution as a map you can actually navigate, the one-trigger-per-object rule and the handler pattern that enforces it, bulkification as a reflex rather than a review comment, and recursion control that does not break batch two.

Prerequisites

Apex for Absolute Beginners through lesson 05, or working knowledge of classes, SOQL and DML. Every section assumes you can deploy a class to a Developer Edition.

How the sections chain

Five sections in publish order: first the map (what runs when you press Save), then the rule, then the pattern that implements the rule, then the discipline that keeps it fast at 200 records — and finally the guard that keeps it from calling itself.

What you'll be able to do

  • Sequence any save's automation from memory
  • Refactor multi-trigger objects to one trigger + handler
  • Write collect–query–map–loop–DML without thinking
  • Test at 200 records, not one
  • Break recursion with an Id set, not a boolean

The sections

  1. 01 · Order of execution, the map Before triggers, validation, after triggers, assignment rules, flows, roll-ups — what actually runs when you press Save. 15m
  2. 02 · One trigger per object Two triggers on one object run in an order Salesforce refuses to promise. The fix is a rule, not a framework. 10m
  3. 03 · The handler pattern One method per event, a static bypass flag, and constructor-free classes your tests will thank you for. 15m
  4. 04 · Bulkification: 200 records or bust Triggers receive up to 200 records at once. Every query and DML statement inside a loop is a countdown to 'Too many SOQL queries: 101'. 15m
  5. 05 · Recursion control Your after-update updates the record, which fires your after-update. Breaking the loop without breaking legitimate re-entry. 10m