Is it possible to get the ID of a Contact which is part of a Person Account?
I have a custom object which has a custom field referencing the Person Account, though it seems to be referencing the Contact directly. I have created a button which I am using to pass the ID into a Visualforce Page.
With the Insert Field drop-down on the create/edit button page I can put in {!Account.Id}
or {!Contact.Id}
but neither of these work. The Account ID is placed in the URL but is not the correct ID and the Contact ID is blank, which I assume is because the button is on a Person Account page and not a Contact Page.
Attribution to: Nalum
Possible Suggestion/Solution #1
I had an issue accessing this field, I solved it by creating a formula field on the account object to show it - the formula was simply PersonContact.Id
Attribution to: Darren Ferneyhough
Possible Suggestion/Solution #2
Using the Schema Builder, I see the Account object has a "Person Contact" field, that is a Lookup(Contact). That is the only filed I see that seems to reference Person Accounts.
Edit: Double-clicking on that field shows the field name to "Person_Contact".
Attribution to: Mike Chale
Possible Suggestion/Solution #3
I Up-voted Mike Chale as he pointed me in the right direction.
To get this to work I use the Account.Id
to get the Account.PersonContactId
which is then used in my Custom Object.
Account a = [Select PersonContactId From Account Where Id = :AccountId];
CustomObject co = [Select Name From CustomObject Where Client__c = :a.PersonContactId];
There doesn't seem to be a way to get this value in the Merge Field drop-down list on the create/edit button page.
A list of all person account fields can be found in the documentation. Scroll 2/3 down the page to the section titled "IsPersonAccount Fields".
Attribution to: Nalum
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/207