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[] {'bhagchand.manshani@infostretch.com'};
      mail.setToAddresses(toAddresses);
      mail.setSubject('Qmetry Instance Already Exist......');
        mail.setUseSignature(false);
           String Msg='Here are the Following Details';                                                                                  
             mail.setHtmlBody(Msg);
              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

Hi

 

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...

nicktangnicktang

may be this can help you

Trigger.new.yourFields__c.addError('bad');