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
Knight12@tarunKnight12@tarun 

Inserting account field in visual force page having Person Accounts Record types

Error message while updating Person Account through visual force wizard

 herei s my code 

 

 

<apex:page controller="patientController" tabStyle="Opportunity" sidebar="false" showHeader="false">
<apex:form >
<apex:pageBlock title="Record Type">
<apex:pageMessages />
<apex:pageblocksection >
<apex:panelGrid >
<apex:outputLabel value="Record Type" for="recordtype"/>
<apex:inputField id="recordtype" value="{!PersonAccount.RecordTypeId}"/>


</apex:panelGrid>
</apex:pageblocksection>

 

<apex:pageBlockSection title="Contact Information">
<apex:panelGrid columns="2">
<apex:outputLabel value="Name" for="perfirstName"/>
<apex:inputField id="perfirstName" value="{!PersonAccount.Name}"/>
</apex:panelGrid>
</apex:pageBlockSection>


<apex:facet name="footer">
<apex:outputPanel >
<apex:commandButton action="{!step1}" value="Next" styleClass="btn"/>
</apex:outputPanel>
</apex:facet>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

 

Class.patientController.save: line 70, column 1     

 

 

while inserting the Person account error is 

 

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Account: bad field names on insert/update call: Name: [Name]

Error is in expression '{!save}' in component <apex:page> in page docinfopage

 

Any one please need a suggestion 

 

 public PageReference save() {   

PersonAccount.RecordTypeId=PersonAccount.RecordTypeId;
insert PersonAccount;

PageReference orderPage = new PageReference('/' +PersonAccount.id);
orderPage.setRedirect(true);

return orderPage;
}

 

 

Thanks In advance,

Newbie @ knight12

Shailesh DeshpandeShailesh Deshpande
I am not sure but I think you probably need to use firstName and lastName fields instead of Name field. Secondly, you might also need to set isPersonAccount field to true.
Vinit_KumarVinit_Kumar

With person Account you should be inserting values for firstname and last name,then only you can perform insert operation for any record.