You need to sign in to do that
Don't have an account?
Reddivari Manjunath
ExampleTrigger in trailhead practice
Hi,
I am new salesforce and struggling with triggers.Now i am try to execute the sample trigger which was send mail to mentioned email with description.below the code which i am working now.its executed successfully but not triggered the mail to mentioned mail.
trigger ExampleTrigger on Contact (after insert, after delete) {
if (Trigger.isInsert) {
Integer recordCount = Trigger.New.size();
System.debug(':::countrecords:::'+recordCount);
// Call a utility method from another class
EmailManager.sendMail('emailtomanjur@gmail.com', 'Trailhead Trigger Tutorial',
recordCount + ' contact(s) were inserted.');
}
else if (Trigger.isDelete) {
// Process after delete
}
}
I am new salesforce and struggling with triggers.Now i am try to execute the sample trigger which was send mail to mentioned email with description.below the code which i am working now.its executed successfully but not triggered the mail to mentioned mail.
trigger ExampleTrigger on Contact (after insert, after delete) {
if (Trigger.isInsert) {
Integer recordCount = Trigger.New.size();
System.debug(':::countrecords:::'+recordCount);
// Call a utility method from another class
EmailManager.sendMail('emailtomanjur@gmail.com', 'Trailhead Trigger Tutorial',
recordCount + ' contact(s) were inserted.');
}
else if (Trigger.isDelete) {
// Process after delete
}
}
have you create the 'EmailManager' apex class? if not create apex class from here (https://trailhead.salesforce.com/en/modules/apex_database/units/apex_database_intro):
after that tell me the steps how you validate this trigger
thanks
All Answers
have you create the 'EmailManager' apex class? if not create apex class from here (https://trailhead.salesforce.com/en/modules/apex_database/units/apex_database_intro):
after that tell me the steps how you validate this trigger
thanks
If your Salesforce Administrator has configured the Email Administration | Deliverability in your org with No Access then it restricts emails from your org ( Production or sandbox) and to resolve this one of your Salesforce Administrators needs to change the Deliverability to All Emails .
Let us know if this will help you
I hope your EmailManager class is like below
Yes i created the 'EmailManager' at first only.After that i run through Debug anonymous window with following code.its successfully executed but i didnt get any mail with mentioned message and also set the email seetings also.
Contact c = new Contact(LastName='Test Contact');
insert c;
Thanks for your valuable solution.its executing but not triggering mail and in debug log nothing will be showing.in trigger showing some compile error while calling the sendMail method.below the error message.
"Non static method cannot be referenced from a static context: void EmailManager.sendMail(String, String, String)"
got executed.Thanks once again for your valuable solution.
Regards,
Manjunath
that worked for me too!