6

I'm building a UI to help my users merge duplicate custom objects. My understanding is that with API version 29, it's now possible to merge any sObjects, not just Contact, Lead, and Account as before. But when I try to save my code (pseudo-code here)

Service__c keep = getTheOneToKeep();
List<Service__c> others = getTheOnesToLose();
// finally, merge the services
merge keep others;

I get this error:

Compile Error: Specified type SOBJECT:Service__c cannot be merged.

I've checked that the class is being saved with API version 29 in its metadata. What am I missing?

UPDATE: Here's the merge syntax from the documentation linked to above:

merge sObject sObject
merge sObject sObject[]
merge sObject ID
merge sObject ID[]
2
  • Is it because you have a list and a object? Nov 26, 2013 at 18:32
  • That should be acceptable syntax, according to the documentation...
    – Benj
    Nov 26, 2013 at 18:54

1 Answer 1

5

Merge Any Object is not a delivered Idea on the IdeaExchange, so it seems that what you're looking for doesn't exist yet. Also, there is no "MasterRecordId" field on custom objects, which suggests that merging isn't implemented yet. You will have to go through the painstaking process of manually merging the records through code: query all relationships, reparent the records, then delete the merged record(s). Finally, the documentation doesn't explicitly state that you can merge any object, which should be proof enough that you cannot merge any object (if you could, it would be documented explicitly).

3
  • Bummer! I guess I misunderstood that - as did the SFDC employee who looked over this with me during a Code Consultation last week at Dreamforce :(
    – Benj
    Nov 26, 2013 at 21:27
  • That figures. At least it's out in the open. We need to vote for the idea. I have been longing for a merge function for ages myself; our project would greatly benefit from this feature.
    – sfdcfox
    Nov 26, 2013 at 21:42
  • I refactored for this, and it's much more bulk-safe as a result, too (as long as I know what all the child objects are. I didn't use Describe to check for all the possibilities...)
    – Benj
    Nov 27, 2013 at 21:50

You must log in to answer this question.

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