Process Automation and Logic28% of the exam

Transactions, the save order and recursion

How an Apex transaction commits or rolls back as one unit, where before-save flows, triggers and validation rules sit in the save order of execution, how DML and roll-up summaries cascade into more saves, and how savepoints and transaction-scoped static variables control rollback and recursion.

Official exam objective
Describe the relationship between Apex transactions, the save order of execution, and the potential for recursion and/or cascading.

~8 min read · 9 practice questions ·

What the exam expects

  • Predict what survives an unhandled exception in an Apex transaction.
  • Place before-save flows, triggers, validation rules, roll-ups and the commit in the save order, and predict what a validation rule sees.
  • Recognise cascading: DML, flows and roll-up summaries that send another record through its own save.
  • Diagnose trigger recursion and choose the fix: move same-record updates before the save, or guard re-entry with a static variable.
  • Use Database.setSavepoint() and Database.rollback(), and know their limits.

Key terms: transaction (operations that commit or roll back together); save order of execution (the fixed sequence Salesforce runs on insert, update or upsert); cascading (one save starting another record's save); recursion (automation re-firing because of its own DML); savepoint (a point you can roll the database back to).

Key facts

Transaction failure
Detail
An error in any operation rolls back the entire transaction; nothing is committed
When DML commits
Detail
Once, after roll-ups and criteria-based sharing, near the end of the save order
Before-save flow position
Detail
Immediately before Apex before triggers
Custom validation rules
Detail
Run after before triggers, so they see values those triggers set
Modifying Trigger.new
Detail
Allowed only in before triggers; after-trigger records are read-only
Roll-up summary
Detail
Parent (and grandparent) records go through their own save procedure
Recursive save
Detail
Skips steps 9 (assignment rules) through 17
Static variable scope
Detail
One transaction; persists across trigger invocations, reset for the next transaction
Savepoint cost
Detail
Counts toward the DML statement limit
Rollback and statics
Detail
Static variables aren't reverted by a rollback
Sources for this section (7)
  • Why does a value set on Trigger.new in a before insert trigger need no DML statement?
  • When does inserting a detail record fire triggers on its master?
  • Why does a static Boolean in a helper class stop trigger recursion when an instance variable does not?
  • Which savepoint becomes invalid when you roll back to SP1 after creating SP1 and then SP2?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the Platform Developer pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 21 lessons of the Platform Developer guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (9 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the Platform Developer exam