You need to sign in to do that
Don't have an account?
Gemini@Work
Unable to get the "email" field of a Person-Account via Apex
In the Org I'm currently working with, they have Person-Accounts enabled.
In Person-Accounts, "email" is a valid field in the Account object. I've been able to use the email field in Page layouts, and update the field via the standard UI -- but I am unable to query or write to the field in Apex.
Instead, I get an error message that "email" is not a recognized field for the Account object:
Is there a method for accessing the "email" field on Person-Accounts?
The field is Account.PersonEmail.
(Hint: Use Data Loader to do a full SOQL "describe" of the object by telling it to export all fields and then just doing a copy/paste on the generated SOQL.)
(Hint2: Use Excel Connector to describe the object and pull the field names from that.)
Great question, especially since it provides a place to remind all that custom PersonAccount fields end with __pc, which is just plain odd! :)
All Answers
A person account is an agglomeration of an Account and a Contact. Try
Select email From Contact where AccountId=<your account ID>
The field is Account.PersonEmail.
(Hint: Use Data Loader to do a full SOQL "describe" of the object by telling it to export all fields and then just doing a copy/paste on the generated SOQL.)
(Hint2: Use Excel Connector to describe the object and pull the field names from that.)
Great question, especially since it provides a place to remind all that custom PersonAccount fields end with __pc, which is just plain odd! :)
Thanks, David Schach (and Kingsley, too, for the Twitter assist).
PersonEmail was the way to go:
facEmail = [select id, PersonEmail
from Account
where id = :System.currentPageReference().getParameters().get('fac1')];
The field names that I looked at in the DataLoader this afternoon were not the same ones I looked at in the same DataLoader last night at 2:00am. :-D