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
Sandy singhSandy singh 

Error:"Account Name: Account: bad field names on insert/update call: Name"

Hi ,

 

I am getting Error:"Account Name: Account: bad field names on insert/update call: Name" once trying to update Account object from apex Controller.

 

Apex Code:

public class sampleController{

public Account acc = new Account();

 

public PageReference save(){

acc.PersonMailingStreet = 'bangalore';

acc.PersonMailingCity = 'abc';

update acc ;

return null;

}

}

 

can anyone help me on this.

 

Thanks in advance,

Sandy

Navatar_DbSupNavatar_DbSup

Hi,

 

In Order to update you need to create the refrence of Account by giving the ID for that account. Then after that do the updation

Account acc = new Account(id='0019000000AGHT7');
acc.AccountNumber='1234';
update acc ;

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

Mitesh SuraMitesh Sura

What Navatar says is true. 

 

If the code is in a controller , you can get the account id:

AccountId = ApexPages.currentPage().getParameters().get('id'); 

 You can reference this Id, to update the account details. 

 

Hope this helps

 

regards

SF Partner