I use the native merge functionality to glue two duplicate contacts together programmatically:

merge target source;

Yet this invokes the following error:

12:06:49:251 USER_DEBUG [46]|DEBUG|DML_e: Merge failed. First exception on row 0 with id 0030-removed---tQAG; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.: [Name]

I'm confused. For once, the Name field is exactly the same for both contacts. Also, I thought my Apex would run with maximum permissions in any case.

What is a good way to merge two Contacts, ideally copying tasks, attachments etc as well?


Name is not a writable field (it's a composite of multiple fields). You must use FirstName, MiddleName, LastName, Suffix, and Salutation, as appropriate. You must not query the Name field, or you'll get this error. The merge syntax will, as you surmise, link all child records (attachments, tasks, etc) to the surviving record.

  • Oh yes, of course. I sort of missed the obvious. Thank you very much for your quick and insightful reply! – Blake Mar 1 '19 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.