Preface – This post is part of the Write Your First Intermediate Trigger series.
Chapter 4 Questions:
1. Without SOQL, what fields are available for each record entering a trigger?
2. What character must be placed before every Apex variable used in a SOQL query?
3. What does an error look like to the end user when adding an error to a record using the .addError() method?
4. Why shouldn’t a developer query for production records in a test class?
5. Why should every test class use System.assertEquals(), even if your code works 100% of the time?
6. What’s the negative test case for a trigger that divides the Amount by the number of days until the Close Date?
7. Which is the correct way of using System.assertEquals()?
System.assertEquals(‘English Bulldog’, favoriteDog);
System.assertEquals(favoriteDog, ‘Toy Poodle’);
Chapter 4 Practice Trigger
Write a trigger on Leads that checks to see if another Lead or Contact has the exact same name. If so, populate a “Potential Lead Duplicate” or a “Potential Contact Duplicate” field. Don’t forget the test class!