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
bhagya manshanibhagya manshani 

Send Email Before AddError ..........Please help

   Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

    String[] toAddresses = new String[] {''};
      mail.setSubject('Qmetry Instance Already Exist......');
           String Msg='Here are the Following Details';                                                                                  
              System.debug('Final Message '+msg);                 
              Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });



// Email Part End Here

  // Trigger.old[0].addError('metry Instance Already Exist flag value.');      // Not Working

   //lead.Company.addError('Qmetry Instance Already Exist flag value ....... ');                            // Not Working

  // Trigger.oldMap.get(lead.Company).addError('metry Instance Already Exist flag value.'); // Not Working


Please Help Thanks in Adv.


Sanchit SinghalSanchit Singhal



Your post seems to lack a few essential must knows:


- what is the trigger type you are using Before/Update, insert/Update.

- also the actual exception/error you are getting you are getting.


, also you cannot use addError() with an instance of Trigger.old, plus trigger.old is not available with after/before insert triggers.


Hope this info helps...


may be this can help you'bad');