Salesforce offers programmatic merge support only for Lead, Contact, and Account records using the
merge DML operation:
Only leads, contacts, and accounts can be merged
To merge custom objects, you'll need to define the merge semantics yourself, and you can't, unfortunately, take advantage of the native
merge operation's reparenting support.
To do this whole objective, you'd have to
- Define logic to locate duplicate records.
- Define logic for selecting a "winning" and "losing" records.
- Define logic for how field values from the source objects are combined, or which records' values survive.
- I'm assuming your duplicates all share a parent and don't have their own children; otherwise, you have some additional reparenting considerations.
- Write code to merge those field values, delete losing records, and update winning records.
- Write batch and/or scheduled Apex to perform this entire operation on a regular basis.
As an alternative to a not-insubstantial project, you might consider one of the many available third-party duplicate management products, at least some of which (I won't name names here because I'm not a fan of the vendor involved) offer bulk merge of custom objects out of the box.