Salesforce Apex Triggers
Complete Interview Prep Series
The most comprehensive free Apex Triggers interview preparation — from theory to write-the-code. Built by a developer, for developers. No paywall. No signup.
Apex Triggers are the most tested topic in every Salesforce Developer interview — from junior to senior level. Interviewers ask both theory questions ("What is a before trigger?") and hands-on coding questions ("Write a trigger for this scenario").
This series covers everything you need — theory, bulkification, handler patterns, advanced async triggers, and 30 real write-the-code questions with complete working code. All free, no paywall, built by someone actively working in the ecosystem.
- ⚡ What is a trigger? Syntax & structure
- 🔄 Trigger contexts — before vs after
- 📋 Trigger.new, Trigger.old, Trigger.oldMap
- 🚀 Governor limits in triggers
- 🔁 Order of execution explained
- ⚙️ Trigger vs Workflow vs Flow
- 🏗️ Best practices — handler pattern
- 📊 50+ theory questions covered
- ⚡ Q1–Q6: Basic triggers — must know
- 🔥 Q7–Q12: Bulkification patterns
- ✅ Q13–Q18: Validation & business rules
- 🏗️ Q19–Q22: Handler pattern & best practices
- 🚀 Q23–Q27: Advanced — @future, Queueable
- 🏢 Q28–Q30: XYZ Company scenario based
- 💡 Every answer: code + why + mistake + example
- 📊 30 complete working trigger code examples
⚡ Trigger Basics
Syntax, contexts, Trigger variables, before vs after, insert/update/delete/undelete
🔥 Bulkification
SOQL in loop fix, Maps vs Sets, AggregateResult, bulk DML patterns — the #1 interview filter
🏗️ Handler Pattern
One trigger per object, handler class architecture, separation of concerns, testability
🔄 Recursion Prevention
Static boolean flag, try/finally pattern, why recursion happens, how to prevent it
✅ Validation Triggers
addError(), field-level vs record-level errors, profile-based rules, stage transitions
📊 Audit & Logging
Field change detection using Trigger.oldMap, audit log creation, Database.SaveResult
🚀 Async Apex
@future(callout=true), Queueable chaining, when to use each, System.enqueueJob
⚙️ Custom Metadata
Configurable business rules without code deployment, round-robin assignment, rollup triggers
🏢 Scenario Questions
Real XYZ Company scenarios — Visit Reports, Order protection, Closed Won handling
🔀 Merge Handling
MasterRecordId, auto vs manual reparenting, custom object orphan prevention
📦 Custom Rollup
Why standard rollup isn't always enough, AggregateResult rollup pattern, all 4 DML events
⚠️ Error Handling
Database.insert(list, false), partial success, SaveResult[], Error_Log__c pattern
💡 How to Prepare for Apex Trigger Interviews
- 1️⃣Start with Part 1 Theory — understand concepts before writing code. Know what before/after means, what Trigger.old contains on delete, governor limits.
- 2️⃣Master Bulkification first — 80% of Apex trigger interview feedback is "not bulkified". No SOQL in loops. No DML in loops. Always use Maps and Sets.
- 3️⃣Practice the Handler Pattern — every senior Salesforce developer interview asks about this. One trigger per object. Logic in handler class.
- 4️⃣Write code out loud — interviewers want to hear your thought process. Explain what context you're using and why before writing the code.
- 5️⃣Prepare 2-3 real examples — "At my previous company, we had a trigger that..." is gold in interviews. Use the XYZ Company examples in this guide.
🚀 sfinterviewpro.com
1,200+ questions across 18 topics. 3 free courses. Always free. No paywall. No signup. Built by a Salesforce developer for the community.
Part 1: Theory → Part 2: Code →