Fix a missing null check
Calling a method on a blank field throws Attempt to de-reference a null object.
Your task
Fix the handler so Leads with a blank Email are skipped, and every other Lead still gets its domain in Description.
public class AS_A276BDF2054F_EmailTidy {
public static void beforeInsert(List<Lead> leads) {
for (Lead lead : leads) {
String email = lead.Email.toLowerCase();
lead.Email = email;
lead.Description = 'Domain: ' + email.substringAfter('@');
}
}
}Requirements
- lowercasesEmailAndSetsDomain should pass
- leavesABlankEmailAlone should pass
- insertsWhenEveryEmailIsBlank should pass
- handlesMixedBulkOfTwoHundred should pass
- usesStringIsBlank should pass