function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
stibbettstibbett 

Associate new PersonAccount with existing contact

I have a few thousand contacts and we're switching to Person Accounts since we're essentially a B2C company.

I'm writing a migration script using the API. I have a particular Contact, and I want to create a new PersonAccount associated with that contact.

I've tried just creating the account with the PersonAccountId value set to the contact's Id, but that gives me an error.
 
conn.sobject("Account").create({
      FirstName: contact.FirstName,
      LastName: contact.LastName,
      PersonAccountId: contact.Id
    });
That gets me 
INVALID_FIELD_FOR_INSERT_UPDATE: Unable to create/update fields: PersonContactId
I can see the PersonContactId field in the Account when I query it, but I guess it's read only.

What's the proper way to do this?

Thanks
 -- Steve

 
stibbettstibbett
Sorry, the code block should be:
conn.sobject("Account").create({ 
  FirstName: contact.FirstName, 
  LastName: contact.LastName, 
  PersonContactId: contact.Id 
});