+ Start a Discussion
pcave_jrpcave_jr 

leadDuplicatePreventer cookbook code fails testing when converted to contacts

I'm using the leadDuplicatePreventer from the force platform cookbook to prevent duplicate emails. I've altered it to use the contact object instead of the lead object and it will not pass test coverage.

 

// Seed the database with some leads, and make sure they can // be bulk inserted successfully. Contact contact1 = new Contact(LastName='Test1', Email='test1@duptest.com'); Contact contact2 = new Contact(LastName='Test2', Email='test4@duptest.com'); Contact contact3 = new Contact(LastName='Test3', Email='test5@duptest.com'); Contact[] contacts = new Contact[] {contact1, contact2, contact3}; insert contacts; contact2.Email = 'test2@duptest.com'; contact3.Email = 'test3@duptest.com'; update contacts;

 

It fails on the update call that changes the originally inserted contact records even though they are not duplicates.

 

Does anyone know why this would happen? I understand most of the code in the duplicatePreventer class except for the System.Trigger.oldMap part.

 

Thanks,

Phillip

jkucerajkucera

Can you post the exact error you're seeing?

 

btw-I haven't seen the leadDuplicatePreventer code - what page is it on?