1
0

sample.apex.txt 362 B

1234567
  1. /* Using a single database query, find all the leads in
  2. the database that have the same email address as any
  3. of the leads being inserted or updated. */
  4. for (Lead lead : [SELECT Email FROM Lead WHERE Email IN :leadMap.KeySet()]) {
  5. Lead newLead = leadMap.get(lead.Email);
  6. newLead.Email.addError('A lead with this email address already exists.');
  7. }