You need to sign in to do that
Don't have an account?
Aishwarya P 4
Please help me write the class.
When an Opportunity is deleted, a mail should be generated to inform the Owner of the Account informing him about this.
//Trigger:
trigger EmailOnDelete on Opportunity (after delete) {
Messaging.reserveSingleEmailCapacity(trigger.size);
List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
for (Opportunity opp : Trigger.old) {
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(new String[] {'ash@gmail.com'});
email.setSubject('Trigger on Oppurtunity Activated : Deleted Account Alert');
email.setPlainTextBody('This message is to alert you that the account named ' + opp.Name + ' has been deleted.');
emails.add(email);
}
Messaging.sendEmail(emails);
}
I'm able to write the trigger, But i want a class method to be called in trigger and all the actions to happen in the class method.
//Trigger:
trigger EmailOnDelete on Opportunity (after delete) {
Messaging.reserveSingleEmailCapacity(trigger.size);
List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
for (Opportunity opp : Trigger.old) {
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(new String[] {'ash@gmail.com'});
email.setSubject('Trigger on Oppurtunity Activated : Deleted Account Alert');
email.setPlainTextBody('This message is to alert you that the account named ' + opp.Name + ' has been deleted.');
emails.add(email);
}
Messaging.sendEmail(emails);
}
I'm able to write the trigger, But i want a class method to be called in trigger and all the actions to happen in the class method.
Please create another Class and call this class from trigger by passing (trigger.new, trigger.oldMap).
Let me know if you still face any issue, or you can directly contact me on below details.
Thanks,
Gaurav
Skype: gaurav62990