12

Apex has a Transaction Control system for rolling back changes to SObjects. Are Custom Settings included in a rollback? (To be more clear, are Custom Settings reverted to the state that they were in when setSavepoint() was called?)

14

Yes, they are. In fact changes you wouldn't think of as DML are also rolled back: calling @future method, sending email, and others. In essence outside of the current apex state rolling back undoes EVERYTHING you did.

Note that Big Objects are the exception to this, they commit immediatley and do not support rollbacks. Even in tests.

Platform events are also not able to be rolled back (but don't fire real event handers form tests like Big Objects do)

  • Platform events are also not able to be rolled back (but don't fire real event handers from tests ... ? This is unclear - in a test context, if you publish a platform event and the consumer is a trigger, my understanding is the trigger will execute at Test.stopTest or on Test.getEventBus().deliver(); even if the published event was within a setSavepoint-rollback frame. – cropredy Jul 24 '18 at 0:13
  • @cropredy that's right, sorry for my unclear choice of words. I just meant to denote that platform events fired from apex triggers don't end up saved outside of the test context, unlike big objects (developer.salesforce.com/docs/atlas.en-us.bigobjects.meta/…) – ca_peterson Jul 24 '18 at 4:47
5

Any DML in the transaction is rolled back, including custom settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.