0

I'm trying to delete a Contact using apex :

String stringId = '0031400002qCxIcAAK';
Contact record = Database.query('Select Id From Contact Where Id = :stringId');
delete record;

And I have this error :

FATAL_ERROR System.DmlException: Delete failed. First exception on row 0 with id 0031400002qCxIcAAK; first error: INVALID_PERSON_ACCOUNT_OPERATION, cannot reference person contact: []

  • You are working with Person Accounts? – Koen Certyn Dec 2 '19 at 14:27
  • yes, i'm trying to delete person account created by web service. – Cedric Hollard Dec 2 '19 at 14:29
2

i would recommended go through Person Contact , person contact created/deleted automatically with Person Account, so person contact you can only modify, if you want delete Person contact you should delete person account then person contact delete automatically.

A person contact can be modified, but cannot be created or deleted. Since these kinds of contacts do not have their own record detail page, clients must redirect users to the corresponding person account (Account) page. SOSL results don’t include any of the contact fields enabled when IsPersonAccount is set to true. The contact ReportsToId field is not visible.

If you delete the account, the contact is also deleted. You cannot directly delete the contact; you must delete the account.

  • I understand the logic, thank you for your help ! – Cedric Hollard Dec 2 '19 at 14:43

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.