Skip to main content

SF-0325 · Concept · Easy

What are the different types of trigger events in salesforce?

✓ Verified by Vikas Singhal · Last reviewed 5/17/2026 · Updated for Spring '26

Salesforce supports seven trigger events in total — a combination of two timings (before, after) and four DML operations (insert, update, delete, undelete). You declare any combination you need in the trigger signature, and Salesforce calls your code at exactly those moments.

The seven events

EventFires whenTrigger.newTrigger.old
before insertRecords about to be insertedYes (writable)No
before updateRecords about to be updatedYes (writable)Yes
before deleteRecords about to be deletedNoYes
after insertRecords just insertedYes (read-only)No
after updateRecords just updatedYes (read-only)Yes
after deleteRecords just deletedNoYes
after undeleteRecords restored from Recycle BinYes (read-only)No

Two events you might expect — before undelete and any merge event — don’t exist. The platform handles merge by firing standard delete and update events on the losing and surviving records.

Declaring multiple events on one trigger

trigger ContactTrigger on Contact (
    before insert, before update, before delete,
    after insert, after update, after delete, after undelete
) {
    new ContactTriggerHandler().run();
}

Inside the trigger, branch on Trigger.operationType or the Trigger.isInsert / isUpdate / isDelete / isUndelete and Trigger.isBefore / isAfter booleans to route to the right logic.

Picking the right event

  • Set defaults or validate before save? Use before insert and/or before update. You can mutate Trigger.new directly — no DML required.
  • Create child records that reference the parent’s Id? Use after insert — the new records have IDs only after insert.
  • Block a deletion? Use before delete and call record.addError(...).
  • Roll up changed values to a parent record? Use after update, compare Trigger.new against Trigger.oldMap, and update parents in bulk.
  • Re-derive a calculated field on restore? Use after undelete.

Common interview follow-ups

  • Is there a before undelete event? — No. The platform only exposes after undelete.
  • What fires when a record is merged? — Standard delete events on the losing records and update on the master. There’s no dedicated merge event.
  • Can one trigger handle multiple events? — Yes, and the “one trigger per object” best practice depends on it.

Verified against: Apex Developer Guide — Trigger Syntax. Last reviewed 2026-05-17 for Spring ‘26.