function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tdevmantdevman 

before insert and update question

As a best practice, i know that we need to gracefully recover from exceptions and one way is to handle the transaction is by creating a record in a custom log object.  However, after readung up, i think this will not work on a before insert/update since the transaction is rolled back completely which would prevent the error to be inserted into the object unless it;s an after insert/update.

 

 Is this true? Also if it is, what is a best way to handle exceptions associated with before insert/update triggers?

Anoop AsokAnoop Asok

Hello,

When we say gracefully recover from exceptions, its the exception handling using try catch block we're essentially talking about. And if we're logging the exception into a custom object in the catch block, it'll stay even if the records we are trying to insert/update will be rolled back.

 

Thanks,

Anoop