Process Automation, Logic, and Integration27% of the exam

Savepoints, partial success and custom exceptions

What Database.rollback does and doesn't revert, how to call out after a rollback, how allOrNone false retries and re-fires triggers, how to design and chain custom exceptions, and how to log errors that survive a rolled-back transaction.

Official exam objective
Describe and use the Apex features available for error handling and maintaining transactional integrity.

~7 min read · 10 practice questions ·

What the exam expects

  • Predict the database and variable state after Database.rollback(): discarded DML, surviving static variables, Ids left on sObjects.
  • Make a callout after rolling back, using Database.releaseSavepoint().
  • Choose Database.insert(records, false) to keep valid records and read failures from SaveResult, and explain why triggers re-fire on the retry.
  • Design custom exceptions: naming, inherited constructors, chaining a cause, catching by parent type.
  • Recognise what can't be caught (LimitException) and log errors so the log survives a rollback.

Key terms: savepoint (a marker of database state that later DML can be rolled back to); allOrNone (the Database-method flag; true by default, false allows partial success); SaveResult (the per-record result of a Database insert or update); chained cause (an exception passed to another exception's constructor); Publish Immediately (a platform event behaviour that publishes even if the transaction fails).

Key facts

Static variables on rollback
Detail
Not reverted
Id after rollback
Detail
An sObject inserted after the savepoint keeps its Id; re-inserting it fails
Savepoint cost
Detail
setSavepoint and rollback count toward DML statements, not rows
Callout after rollback
Detail
From API 60.0, allowed once uncommitted DML is rolled back and savepoints are released
allOrNone default
Detail
true: one failure throws and saves nothing
Partial-save attempts
Detail
Up to three; limits reset each retry; triggers re-fire on the clean subset
Custom exception name
Detail
Must end with "Exception" and extend Exception
LimitException
Detail
Can't be caught
Synchronous SOQL limit
Detail
100 queries per transaction
Publish Immediately
Detail
Default; published even if the transaction fails
Sources for this section (7)
  • Why does inserting the same sObject variable again after a rollback fail?
  • When does a partial-success insert run a trigger more than once?
  • Which constructor chains a caught exception into a custom one?
  • Why does a Publish Immediately platform event suit error logging?

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

Keep reading with the Platform Developer II pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 28 lessons of the Platform Developer II guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (10 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 II exam