1

I couldn't merge the custom SObject records. It shows an error like

Specified type Candidate__c cannot be merged

My Code is :

// Account creation code

List<Candidate__c> newCandidateList = new List<Candidate__c>();
Candidate__c c1 = new Candidate__c();
c1.Years_of_experience__c = 4;
c1.Last_Name__c = 'Oracle';
c1.First_Name__c = 'Inc.';
newCandidateList.add(c1);

Candidate__c c2 = new Candidate__c();
c2.Years_of_experience__c = 14;
c2.Last_Name__c = 'Oracle Inc';
c2.First_Name__c = 'Inc.';
newCandidateList.add(c2);

Candidate__c c3 = new Candidate__c();
c3.Years_of_experience__c = 24;
c3.Last_Name__c = 'Oracle Inc';
c3.First_Name__c = 'India';
newCandidateList.add(c3);

insert newCandidateList;
system.debug('Insert List are :' + newCandidateList);


// Merging code
Candidate__c childrecords = [
        SELECT Id,
          Name,
          First_Name__c,
          Last_Name__c,
          Years_of_experience__c
        FROM Candidate__c
        WHERE First_Name__c = 'Inc.'
        LIMIT 1];
system.debug('Retrieved Child Records are :' +childrecords);

Candidate__c masterecord = [
        SELECT Id,
        Name,
        First_Name__c,
        Last_Name__c,
        Years_of_experience__c
        FROM Candidate__c
        WHERE First_Name__c = 'India'
        LIMIT 1];
system.debug('Master Records :' + masterecord);

try{
    merge masterecord childrecords;    
} catch (Exception de){
    system.debug('Error during merging the records :' + de.getMessage());
}

2 Answers 2

3

Salesforce will allow you to use merge operation on Account, Contact, and Lead.

As of now, I am not entirely sure if SF is supporting the merge of custom object records. It appears from this Idea that it is still under consideration.

There is an app you can use directly from the appexchange and it's called Dupe Eliminator.

2

There are only 3 objects that support merge: Account, Contact, and Lead.

See here, under "Merging Considerations"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .