1

I'm currently migrating around 2000 accounts to person account via apex. For some reason, it fails on one account. I have checked that it meets all the criteria (one child contact, same owner, same currency, no Parent Account etc..) and it still fails. The logs just say:

System.DmlException: Update failed. First exception on row 316 with id 0011v00001yl1CHAAY; first error: INVALID_PERSON_ACCOUNT_OPERATION, account cannot be converted to person-account: []

Does anyone know a way to get more info about the error?

0

From Setting Up Person Accounts:

Prepare Business Accounts to be Converted to Person Accounts

Each account and contact that you plan to convert to must meet these conditions.

  1. Each account must have one contact. It can’t have more than one.
  2. The account and contact must have the same record owner.
  3. The account and contact must have the same currency values.
  4. The Parent Account field on the Account must be blank.
  5. The Reports To field on the Contact must be blank.
  6. The Account is not set as a Parent Account for any other accounts.
  7. The Contact is not set as a Reports To for any other contacts.

You didn't mention steps 5-7 in your post, and in particular 6 and 7 are the most likely to trip people up. Double check that no records look up to either the Account or the Contact via ParentId and ReportsToId, respectively. If you have verified with 100% certainty that each of the above criteria is fulfilled, you need to open a support case.

Here is an anonymous script you could use to verify each step. If it runs successfully, you can share it with support and posit that you have encountered a bug.

Account account = [
    SELECT
        OwnerId, CurrencyISOCode, ParentId,
        (SELECT Id FROM ChildAccounts LIMIT 1),
        (SELECT OwnerId, CurrencyIsoCode, ReportsToId FROM Contacts)
    FROM Account WHERE Id = '001...'
];

system.assertEquals(1,
    account.Contacts.size(),
    'Condition 1 violated');

Contact contact = account.Contacts[0];

system.assertEquals(account.OwnerId,
    contact.OwnerId,
    'Condition 2 violated');
system.assertEquals(account.CurrencyISOCode,
    contact.CurrencyISOCode,
    'Condition 3 violated');
system.assertEquals(null,
    account.ParentId,
    'Condition 4 violated');
system.assertEquals(null,
    contact.ReportsToId,
    'Condition 5 violated');
system.assertEquals(0,
    account.ChildAccounts.size(),
    'Condition 6 violated');
system.assertEquals(0,
    [SELECT count() FROM Contact WHERE ReportsToId = :contact.Id],
    'Condition 7 violated');
  • Thanks Adrian, I have done all the above. I just wondered if anyone knew of a way to get more info on the error. FYI the best resource is the implementation guide: resources.docs.salesforce.com/220/latest/en-us/sfdc/pdf/… – Jay Aug 9 '19 at 12:40
  • If you have carefully checked for any child records and found none, then you're pretty much going to have to open a support case. That said, you can always try just setting up a debug log with every setting cranked to the highest level. I haven't had much success with this approach, but it might work for you. – Adrian Larson Aug 9 '19 at 12:42
  • Me neither! ..ok thanks anyway – Jay Aug 9 '19 at 13:11
  • @Jay Try running the above script and see if it passes. – Adrian Larson Aug 9 '19 at 13:46
  • Nice :) Much appreciated but I already checked all the above. This script wouldnt run since my contacts are still associated to the accounts. My apex takes care of creating new accounts and reparenting them. I have run the individual assertions via soql already though and its not the issue. Im wondering if it's something to do with the owner permissions or something weird. I'll let you know what support say – Jay Aug 9 '19 at 14:17

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.