I need to capture exceptions that happen during trigger executions in a custom object.

The conclusion here, is that there is no way to do this. Is it possible to hit a Apex webservice callout which records the exception information? (I am afraid of the 'Uncommitted job pending' error)

Also, would like to know if there are any new enhancements around this. Thanks in advance.


A webservice callout would sadly not work here, as callouts aren't allowed from triggers. The usual pattern is to call an @future method from the trigger to perform the callout, but when a database rollback is issued, as in the case when all rows in a DML operation have errors, the @future call itself is cancelled/rolled back. The same applies to sending email.

As far as I know it's not possible to have a trigger result in any side effects when all rows have errors.


In my org, we have a custom ExceptionObject, and we have a util class that can be called anytime with with either 1 or 2 parameters, and the call creates an exception record that can then trigger a workflow on create/insert. That way I can can easily get email notifications if I have an exception.

Since triggers have those limitations, it could be wise to perhaps move trigger operations to a certain trigger pattern, like f/x the iTrigger pattern. This means that whenever you need to do a trigger, the trigger action calls a seperate class that actually does the lifting.

  • 1
    Even if the work is done in a separate class the system-initiated rollback if all rows have errors will impact any DML/future/email invocations made as a result of the trigger. Jan 29 '14 at 0:06

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.