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
ac2sharath1.391056526163461E12ac2sharath1.391056526163461E12 

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}" />
         &nbsp;
         <apex:inputfield value="{!account.FirstName}" />
         </apex:outputpanel>
  </apex:pageBlockSectionItem>
  <apex:inputfield value="{!account.lastname}"
  <apex:inputfield value="{!account.name}"
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>  
</apex:page>
izay.ramos-irizarry1.3893936724146558E12izay.ramos-irizarry1.3893936724146558E12
Hi,

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.