Can I use an addError in an after insert trigger? And if so, is the created object deleted?

2 Answers 2


When you use the addError method in the after insert trigger, the record insertion is reverted back and you wont be able to find the same in the DB.

Actually the after insert trigger fires just before the commit, and any record which is tagged by addError is not commited to DB

  • 7
    Also worth noting that when using addError in "after insert" any autonumber fields do not get reverted - so this results in gaps in the sequence of numbers. Commented Mar 1, 2013 at 16:05
  • The documentation mentions that using addError in the before insert/update causes the error to be displayed on the UI. Is that the case for after triggers as well?
    – LVS
    Commented Jul 20, 2016 at 14:46

You can definitely use addError() on after insert or update and the error messege will be displayed. Transaction will be rolled back.

  • Welcome to SF.SE Pavlo. You may not realize it but you've added a new answer to a 6 yr old question with a correct accepted answer. You'll notice that your answer has been downvoted, most likely because it's incorrect. The transaction will not be rolled back. You may want to double check documentation before answering questions in the future. It's always good to be able to cite documentation as part of your answer. See the Help center for more on Answering.
    – crmprogdev
    Commented Mar 30, 2019 at 18:16

You must log in to answer this question.

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