According to Bulk DML Exception Handling :

Apex triggers are fired for the first save attempt, and if errors are encountered for some records and subsequent attempts are made to save the subset of successful records, triggers are re-fired on this subset of records.

That's fine, but when I modify some records in the first trigger attempt, and mark a few of them with addError(), then the second attempt gets the unchanged subset (without records marked with addError() but also without my modifications on the good ones).

Is there any way to preserve the state between all-or-none before insert attempts?

1 Answer 1


Storing only the good guys in a static collection do the trick. As each trigger attempt run in common transaction, static fields state are preserved, so it's easy to get the values from the previous iteration.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .