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
nabil711nabil711 

Update an account in Customer Portal

Hello

 

I get this error message when i tried to update an account in customer portal:

 

Update failed. First exception on row 0 with id 001f0000001uqh7AAA; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Account: bad field names on insert/update call: Name: [Name]

Erreur dans l'expression '{!enreg}' du composant <apex:page> dans page test

// Visual Force Page Test:

<apex:page controller="MyAccountCon">

<apex:form >
<apex:pageBlock title="Person Account Edit" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!enreg}" value="Save Test"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Personal Data" columns="2">
<!-- Personal Data -->
<apex:inputField value="{!account[0].PersonalReference__c}"/>
<apex:inputField value="{!account[0].PersonBirthdate}"/>
<apex:inputField value="{!account[0].PersonTitle}"/>
<apex:inputField value="{!account[0].Nationality__c}"/>
<apex:outputText value="{!account[0].Name}"/>
<apex:inputField value="{!account[0].Language__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Contact Data" columns="2">
<!-- Contact Data -->
<apex:inputField value="{!account[0].Country__c}"/>
<apex:inputField value="{!account[0].Phone}"/>
<apex:inputField value="{!account[0].PersonHomePhone}"/>
<apex:inputField value="{!account[0].Fax}"/>
<apex:inputField value="{!account[0].PersonMobilePhone}"/>
<apex:inputField value="{!account[0].PersonEmail}"/>
<apex:inputField value="{!account[0].Website}"/>
</apex:pageBlockSection>

</apex:pageBlock>
</apex:form>

</apex:page>

 

// Controller
public class MyAccountCon 
{           

    public List<Account> account=new List<Account>(); 
  
    public List<Account> getaccount()
    {
      //get the user Name from URL
      string usern=apexpages.currentpage().getparameters().get('userName');
      
      //get the account Id
      string idacc=[select accountId from User where username=:usern][0].accountId;
      
      //get the account  
      account = [select PersonalReference__c,Name,PersonBirthdate,Owner.name,Nationality__c,PersonEmail,
                 Language__c,PersonTitle,Country__c,Phone,PersonHomePhone,Fax,PersonMobilePhone,Website
                 from account
                 where id=:idacc];             
      return account;
    }
   public PageReference enreg() 
   {
     update account;

     PageReference pageResult = new PageReference('apex/Moncompte?userName='+apexpages.currentpage().getparameters().get('userName')+'&accountId='+apexpages.currentpage().getparameters().get('accountId')); 
     pageResult.setRedirect(true);
     return pageResult;
   }
    
}
Thanks for Help