5

I want to use addError() to prevent some records from being inserted in a before-insert trigger, and want to ensure that other records in the same transaction are successfully inserted. This requires the inserts to set the allOrNone property to false to allow partial success.

We have inserts coming from both a 3rd party vendor and from in-house calls to the REST api... Is it possible for Salesforce to aggregate a request from our in-house app with a request from the 3rd party vendor in a single call to my before-insert trigger? If so, how does it resolve the allOrNone property if this header is set differently from the two sources?

1 Answer 1

4

No, each individual request is isolated, even if they come from the same user. The flag applies only to the current DML context. It's possible to use this flag in your apex code even when the originating request doesn't request it, but this will only apply to those records modified by the apex code, not the outer transaction. Also, there's no way to tell when allOrNone is in effect. Just trust this flag to do the right thing, and use addError as you'd expect.

You must log in to answer this question.

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