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
opiedogopiedog 

Cannot update a contact

Hi - I'm new to force.com and I've run into what I'm sure is a bonehead config mistake on my part.

 

I'm able to query date in my account - such as contacts.

 

But I haven't figured out how to successfully update a contact. Here's what I'm doing:

* Query for contact A

* Confirm the returned data is as expected

* Change the Name of contact A

* Update contact A

 

This fails with this error:

Code:INVALID_FIELD_FOR_INSERT_UPDATE - Message:Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile.

 

I then tried to not change any fields, and I get the same error.

 

I checked my account in my profile by logging into my account on salesforce.com, then choosing Setup : My Personal Information to confirm I'm an administrator - then I went to App Setup : Contacts : Fields and the Name field shows that it's both required and all the "field-level security for profile" checkboxes are checked (but note that I cannot modify the checkboxes for the Name, FirstName, LastName fields).

 

What am I doing wrong? What do you recommend checking to make sure my account is configured properly?

 

Thanks,

 

John

Best Answer chosen by Admin (Salesforce Developers) 
opiedogopiedog

Found a solution.

 

I was passing the same Contact object that I received from a Get call to the Update call (albeit with a couple fields modified). That Contact object had the Name value already set when it was received in the Get call.

 

If the Name value is cleared before calling Update (i.e. set it to ""), the update succeeds.

All Answers

opiedogopiedog

Also, I am able to successfully update an Account object.

 

The problem is only when I try to update Contact objects.

opiedogopiedog

Found a solution.

 

I was passing the same Contact object that I received from a Get call to the Update call (albeit with a couple fields modified). That Contact object had the Name value already set when it was received in the Get call.

 

If the Name value is cleared before calling Update (i.e. set it to ""), the update succeeds.

This was selected as the best answer
cloudcodercloudcoder

In addition, name is not writable. You need to update Firstname and Lastname, which in turn populates the name field