You need to sign in to do that
Don't have an account?
Alex Valavanis 10
What am i doing wrong? Get started with Apex triggers
Hello, I'm doing the following exercise but Debug LOg tells me i have a problem.
Traihead says to do the following:
I replace my email address and the following comes up:
Traihead says to do the following:
I replace my email address and the following comes up:
and the reason is you can't call something that doesn't exist. Since you haven't created an object, the non-static method doesn't exist yet. A static method (by definition) always exists.
you can learn more about it here : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_static.htm?search_text=static
Hope it wil helps you, if it helps you kindly close your query by choosing best answer so it make proper solution for others in future
All Answers
public static void sendMail(....
after save apex class, save your trigger code,
OR don't change in apex class just update your trigger code with following code :
trigger ExampleTrigger on Contact (after insert, after delete) {
if (Trigger.isInsert) {
Integer recordCount = Trigger.New.size();
// Call a utility method from another class
EmailManager obj = new EmailManager();
obj.sendMail('Your email address', 'Trailhead Trigger Tutorial',
recordCount + ' contact(s) were inserted.');
}
else if (Trigger.isDelete) {
// Process after delete
}
}
Thanks, let us know if it helps you
I am totally new to Apex and this is my first tutorial. What went wrong and why doesn't trailhead updated the instruction ?
I actually don't understand of what you did.
and the reason is you can't call something that doesn't exist. Since you haven't created an object, the non-static method doesn't exist yet. A static method (by definition) always exists.
you can learn more about it here : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_static.htm?search_text=static
Hope it wil helps you, if it helps you kindly close your query by choosing best answer so it make proper solution for others in future