• Ash Ish
  • NEWBIE
  • 5 Points
  • Member since 2018
  • Mr


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hi,

This was working perfectly fine from past so many months and suddenly 2 days back this started throwing an error while executing test classes.

Code to execute
List<Contact> listContact = ContactTestDataFactory.createContact(1, 'FirstName', 'LastName'); insert listContact;

ContactTestDataFactory Test Class -
//Create Contact object 
public static List<Contact> createContact(Integer no_of_contact,String FirstName, String LastName){ 

List<String> lstSalutation = new List<String>{'Mr.','Ms.','Mrs.','Miss.','Dr.','U.S. Senator','U.S. Representative','Governor','Governor’s Cabinet Secretaries','Attorney General','State Senator','State Representative','Judge','Mayor','Consul-General','Ambassador','Ambassador to the U.S.','President of a Country','Former President','Lady','Police Chief','Chief Marshal','Dean','Professor','Priest','Pastor','Monsignor','Cantor','Rabbi','Nun or Sister','Brother','Bishop','Cardinal','Swami'}; 

List<Contact> listContact= new List<Contact>(); Contact objCon = new Contact(); 

for(Integer i=0;i<no_of_contact ;i++){ 
objCon = new Contact(); 
objCon.FirstName= FirstName; 
objCon.LastName= LastName; 
objCon.Salutation= lstSalutation[i]; objCon.Giving_Status__c= 'Prospect'; objCon.npe01__Primary_Address_Type__c = 'Residence'; objCon.MailingStreet = 'test'+i; 
objCon.Street_2__c = 'test 2'+i; objCon.MailingState='test'+i; objCon.MailingCity='test'+i; objCon.MailingCountry='test'+i; 
objCon.Gender__c = 'Female'; 
objCon.FirstName= FirstName; if(i/2 == 0){ objCon.Gender__c= 'Male'; 
} 
else{ 
objCon.Gender__c= 'Female'; 
} 
objCon.Unique_ID__c = String.valueOf(i); listContact.add(objCon); 
} 
System.debug('listContact'+listContact); 
return listContact; 
}

ERROR thrown - 
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, npsp.TDTM_Contact: execution of AfterInsert

caused by: System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []

(npsp)






: []

Any help would be really really appreciated.

I checked other post from Stackexcahnge as well and tried work around but no luck yet.
Stack excahnge similar issue link - https://salesforce.stackexchange.com/questions/79799/how-to-debug-the-mysterious-duplicate-value-found-unknown-duplicates-value-o


--
Kind Regards
Mustafa
Hi,

This was working perfectly fine from past so many months and suddenly 2 days back this started throwing an error while executing test classes.

Code to execute
List<Contact> listContact = ContactTestDataFactory.createContact(1, 'FirstName', 'LastName'); insert listContact;

ContactTestDataFactory Test Class -
//Create Contact object 
public static List<Contact> createContact(Integer no_of_contact,String FirstName, String LastName){ 

List<String> lstSalutation = new List<String>{'Mr.','Ms.','Mrs.','Miss.','Dr.','U.S. Senator','U.S. Representative','Governor','Governor’s Cabinet Secretaries','Attorney General','State Senator','State Representative','Judge','Mayor','Consul-General','Ambassador','Ambassador to the U.S.','President of a Country','Former President','Lady','Police Chief','Chief Marshal','Dean','Professor','Priest','Pastor','Monsignor','Cantor','Rabbi','Nun or Sister','Brother','Bishop','Cardinal','Swami'}; 

List<Contact> listContact= new List<Contact>(); Contact objCon = new Contact(); 

for(Integer i=0;i<no_of_contact ;i++){ 
objCon = new Contact(); 
objCon.FirstName= FirstName; 
objCon.LastName= LastName; 
objCon.Salutation= lstSalutation[i]; objCon.Giving_Status__c= 'Prospect'; objCon.npe01__Primary_Address_Type__c = 'Residence'; objCon.MailingStreet = 'test'+i; 
objCon.Street_2__c = 'test 2'+i; objCon.MailingState='test'+i; objCon.MailingCity='test'+i; objCon.MailingCountry='test'+i; 
objCon.Gender__c = 'Female'; 
objCon.FirstName= FirstName; if(i/2 == 0){ objCon.Gender__c= 'Male'; 
} 
else{ 
objCon.Gender__c= 'Female'; 
} 
objCon.Unique_ID__c = String.valueOf(i); listContact.add(objCon); 
} 
System.debug('listContact'+listContact); 
return listContact; 
}

ERROR thrown - 
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, npsp.TDTM_Contact: execution of AfterInsert

caused by: System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []

(npsp)






: []

Any help would be really really appreciated.

I checked other post from Stackexcahnge as well and tried work around but no luck yet.
Stack excahnge similar issue link - https://salesforce.stackexchange.com/questions/79799/how-to-debug-the-mysterious-duplicate-value-found-unknown-duplicates-value-o


--
Kind Regards
Mustafa