Courseiva

SF-PD2 Testing, Debugging, and Deployment Practice Question

A developer is debugging why a trigger fires twice for a single record save in a sandbox. The trigger is defined on Account with `before insert, after insert` and the class uses a static Boolean guard variable to prevent recursion. Logs show two separate transactions. Which explanation best fits this behavior?

⚠ Common exam trap

The trap here is relying on a static Boolean guard to prevent all re-entry, when a guard cannot cross transaction boundaries created by workflow field updates or related DML.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

A second DML operation on the same Account was performed by another process, such as a workflow field update or a related-record trigger, producing a distinct transaction.

Static variables live only for one transaction, so a guard cannot stop a trigger from firing again when the same record is saved in a new transaction. Workflow field updates, process-driven updates, or DML from a related object's trigger each create a new context, which is why the logs show two distinct transactions and the trigger runs twice.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    The developer should add `with sharing` to the trigger to prevent the second execution.

    Why it's wrong here

    Sharing keywords control record-level access within the running context and have no effect on how often a trigger fires. Adding with sharing would change data visibility for the trigger's queries, not the number of executions. It does not address the two-transaction behavior observed in the logs.

  • ✗

    The static Boolean guard is reset between the before and after phases of the same transaction, allowing the logic to run again.

    Why it's wrong here

    Static variables persist for the duration of a single transaction, including across trigger phases. The guard would not reset between before and after in the same execution context. The observation of two separate transactions points elsewhere, so this explanation does not match the evidence.

  • ✓

    A second DML operation on the same Account was performed by another process, such as a workflow field update or a related-record trigger, producing a distinct transaction.

    Why this is correct

    Two separate transactions indicate the record was saved more than once. A workflow field update re-saves the record and fires the trigger again in a new execution context, and a trigger on a related object performing DML on the Account would do the same. Static guards cannot span transactions, so they cannot prevent this second firing.

  • ✗

    The trigger was deployed twice, so the platform executes both copies for every save.

    Why it's wrong here

    Salesforce permits only one trigger per object per event, so a duplicate deployment would fail or overwrite rather than run twice. The platform would not silently execute two trigger versions. The two-transaction evidence is better explained by additional DML, not by duplicate metadata.

About these practice questions

This SF-PD2 question is part of Courseiva's 226-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Salesforce exam blueprint

This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.