Person Accounts in Salesforce keeps confusing developers not at home on the platform due to their special behaviour. The purpose of the repo (https://github.com/lekkimworld/salesforce-personaccount-field-reference) is to hold some examples on how to work with Person Accounts in an org using Apex and the Bulk API to try and illustrate a few points.
What ARE PersonAccounts
First of knowing WHAT a Person Account is is important. In Salesforce we normally talk about Accounts and Contacts with the Account being the company entity (i.e. Salesforce.com Inc.) and the Contact being the people that we track for that company (i.e. Marc Benioff, Parker Harris etc.). It means that we have to have an Account and a Contact to track a person in Salesforce. But what if that doesn’t make any sense like when tracking individuals for B2C commerce or similar? Meet the PersonAccount.
Please Note: There is no such object as PersonAccount in Salesforce. There are only Account and Contact but in the following I’ll use PersonAccount to reference this special case for Account.
PersonAccount is a special kind of Account that is both an Account AND a Contact giving you the possibility to treat an individual using an Account. The secret to understanding PersonAccount is knowing that using a special record type and specifying it when you create the Account, Salesforce will automatically create both an Account AND a Contact record and automatically link them and thus create the PersonAccount. Salesforce automatically makes the fields that are normally available (including custom fields) on the Contact available on Account. Only thing you need to do is follow a few simple rules that are listed below.
Please Note: When using PersonAccounts you should always access the Account and never the associated Contact.
Because there is both an Account and a Contact for a PersonAccount there are some special rules to follow when referencing fields. This goes for any access whether that be using Apex, REST API and the Bulk API. The rules are pretty easy and are as follows:
- Always reference the Account object
- When creating a PersonAccount create an Account specifying the record type ID of the PersonAccount record type configured in Salesforce. Doing this makes the Account a PersonAccount.
- Fields from Account are available on Account (as probably expected):
- Standard fields from Account Referenced using their API name as usual (i.e. Site, Website, NumberOfEmployees)
- Custom fields from Account Referenced using their API name as usual (i.e. Revenue__c, MyIntegrationId__c)
- Fields from Contact are available directly on Account:
- Standard fields from Contact The API name of the field is prefixed with “Person” (i.e. Contact.Department becomes Account.PersonDepartment, Contact.MobilePhone becomes Account.PersonMobilePhone) UNLESS we are talking FirstName and LastName as they keep their names (i.e. Contact.FirstName becomes Account.FirstName, Contact.LastName becomes Account.LastName)
- Custom fields from Contact The field API name suffix is changed from __c to __pc (i.e. Contact.Shoesize__c becomes Account.Shoesize__pc)
6 thoughts on “Trying to explain Person Accounts in Salesforce”
This is useful to know. I hadn’t come across these special Accounts, but I’m glad to know they exist. Thanks.
Thanks for this explanation! Very helpful. I had the wrong mental model in my head, thinking PersonAccount was a separate object, not a record type of Account.
This is very useful indeed, also the fields populated on the contact (let´s say Test__c), get populated on the account with the same value (Test__pc).
So I guess it is always better to create the field on the contact to have them in both objects when needed that way.
This is better than any explanation I’ve seen from Salesforce. Or at least more concise.
This is helpful. Thank you. I was wondering if you had any feedback about this. We are running into an issue when updating personal account. It throws the below error “This error occurred: INVALID_FIELD_FOR_INSERT_UPDATE: Account: bad field names on insert/update call: LastName, FirstName. “.
What am I missing?
Are you setting the correct record type as well to indicate that it’s a Person account you are inserting?