Salesforce Developer Interview Question

An update trigger keeps creating duplicate child records. What is going on, and how do you fix it?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

The trigger is most likely running more than once in the same transaction, through recursion from its own update, a legacy workflow field update firing update triggers again, a flow updating the record, or a second trigger on the object. Confirm with a debug log. Fix it by making the logic idempotent: act only when the relevant field actually changed, check for existing children before creating them, and add recursion control in the handler.

Why interviewers ask this

Duplicate records from triggers are a classic symptom of not understanding the order of execution. The interviewer wants you to consider every way a trigger can fire again in one transaction, confirm it with logs, and fix it properly. A static Boolean flag is a common but blunt fix that breaks bulk operations, so comparing old and new values and tracking processed record ids shows real experience.

How to structure your answer

  • List the ways a trigger can run more than once.
  • Confirm the cause with a debug log.
  • Make the logic idempotent and based on real changes.
  • Add proper recursion control and a regression test.

Example answer

Spoken example, first person

Duplicates almost always mean the logic ran more than once in the same transaction, so I list how that can happen. The trigger might update the same records and fire itself again. A legacy workflow field update fires update triggers one more time. A record triggered flow might update the record, or there may be a second trigger on the object. A debug log shows the trigger entering twice. For the fix I avoid the common shortcut of a static Boolean that blocks the trigger after its first run, because large updates arrive in chunks of two hundred within one transaction, and the flag can stop later chunks being processed at all. Instead I make the logic idempotent. It only acts when the relevant field actually changed, comparing old and new values, and before creating children it checks whether they already exist. On top of that, the handler keeps a static set of record ids already processed in the transaction. Then I write a test that updates the records twice and asserts exactly one child each.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • Why can a static Boolean recursion flag break bulk updates?
  • How would you stop a flow and a trigger fighting over the same field?
  • How would you clean up the duplicates already created?

Related salesforce developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot