+ Start a Discussion

How to get Person Account's “Last Name” , “salutation” and “First Name” field to Visualforce Page

In my org i have enabled Person Account, and i have a visualforce page where i need to get Salutation,FirstName and LastName field from person account, But when i call it using <apex:inputField value="{!account.lastname}"/> I'm getting only field label here i'm using "account" as a standard controller.

But I have used same line of code i.e <apex:inputField value="{!account.lastname}"/> to get contact's Lastname using "Contact" as standard controller

Here in the below code I'm getting only field label for "Salutation" and "Lastname" but I'm getting both label and field for "Account Name"

can anyone tell me what's problem here ?

<apex:page standardController="Account" extensions="pick_list" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >

   <apex:pageBlockSectionItem >
         <apex:outputlabel value="First Name"/>
         <apex:outputpanel >
         <apex:inputfield value="{!account.Salutation}" />
         <apex:inputfield value="{!account.FirstName}" />
  <apex:inputfield value="{!account.lastname}"
  <apex:inputfield value="{!account.name}"

Your problem is because for person accounts the firstName, lastName, and Salutation (among other fields) are stored in a contact record that is related to the account record. You can use account.PersonContactId to fetch the contact related to that person account to display salutation and last name. You can also use the account.IsPersonAccount to determine if the account is a person account or not and hide/show this fields as needed.

Hope this helps!
Krystal D.  CarterKrystal D. Carter
I know this is years later, but I had the same issue.  I created a custom Salutation field on the Account, and used that field in my visualforce page. Whenever that field is populated initially or it's changed, then it will update the standard Salutation field.  I used the Process Builder to accomplish this population.