Whenever a record is Inserted /Updated, many validations happens and it might Error. Can we capture these Errors at SF object level, no matter from where the Error comes from? I added below trigger but it's not working when there Error due to Duplicate Rules.

trigger EMailFaileds on Contact (before insert, before update, after insert, after update) 
    string RecId = '';
    string siebId = '';
        for(Contact C : Trigger.New)
             RecId =  C.Id;
             SiebId = C.Siebel_Row_ID__c;
    catch(Exception e)
      //Send an Email with record details

1 Answer 1


What you are asking is not entirely possible.

Each entry point will have to capture and handle the errors that are catchable (some are not).

If the insert is initiated from code within salesforce then your code can catch the error (if catchable) and you could write it to a log somewhere.

However, if the error is from say a data load then your external tool would have to review the results and write any error logs.

Since you do not control the duplicate logic provided by salesforce it is up to the entry point to catch and does what is needed with the error

  • Right, may be I posted question too early before using brain. :) There is definitely an ordered execution of operations and when a Rule results in Error, the control might not come back to Triggers. Thanks Eric.
    – Amulya
    Commented Sep 8, 2016 at 20:36
  • 1
    @Amulya - triggers happen as a result of an action. You cannot catch an error in the DML that caused the trigger to execute IN the trigger itself. The code creating the records needs to catch the error.
    – Eric
    Commented Sep 8, 2016 at 20:38

You must log in to answer this question.

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