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

Field is not writeable for custom objects

I have created a custom object(ExtranetSF) using the standard flow( Go to objects-->Create an object-->Create fields and page layout and stuff)
Then I am trying to access that custom object from my visualforce controller. The following piece of code gives me error.It says that "Field is not writeable".

My question is how do i get past this problem??? Any help

ExtranetSF__c co = new ExtranetSF__c();
co.Name = data.getNonUniqueName();
co.Extranet_Name = data.getDomainName();
insert co;

Ron HessRon Hess
you may need to use the api name of the field




co.Extranet_Name__c = data.getDomainName();

however you do not report which field is causing the problem, so it is not possible to give more specific help.
Thanks for the reply..I tried that too...It says that the fields like url_c or extranet_name_c does not exist...
Ron HessRon Hess
custom objects always appear in the API, classes and  controllers with two underscore characters followed by the character 'c'

url_c  <> url__c

look into your WSDL to see these API names,

try this link (if you are on NA1, otherwise adjust the url as needed)*

Thanks Ron...was a was struggling...but am learning fast...thanks...
EDIT:  Nevermind, it was because I had 'name' instead of 'lastname'
Hi guys,
I have a similar problem with my code.
Error: Compile Error: Field is not writeable: Name at line 21 column 3
Here is line 21 = 'Test Lead A';                    // populate required fields
From this method
static testMethod void testAddUpdateNullEmail () {
  // create lead list
  List<Lead> leads = new List<Lead>();
  // create lead records
  Lead leadA = new Lead();                       // create first lead object = 'Test Lead A';                    // populate required fields = 'Acme, Inc.';                  // populate required fields
  leadA.status = 'Open';                         // populate required fields = '';              // populate email field
  leads.add( leadA );                            // add Lead A to list
  Lead leadB = new Lead();                       // create second lead object = 'Test Lead B';                    // populate required fields = 'XYZ Corp.';                   // populate required fields
  leadB.status = 'Open';                         // populate required fields 
  // leave email field null for Lead B 
  leadB.new_email__c = '';     // populate new_email__c since email is null 
  leads.add( leadB );                            // add Lead B to list 
  UpdateNullEmail.addUpdateNullEmail( leads );   // call your method
}  //End of method


Message Edited by jvolkov on 06-17-2008 09:55 AM

Message Edited by jvolkov on 06-17-2008 09:55 AM
Hello jvolkov,

Try to write to the FirstName and LastName fields instead of the combined Name field.

I have a similar problem.  I'm trying to create a button that uses the record ID of a "current record".  The record is in a custom object "Person".  When I try to assign a value from a record to a variable, I get an error.  


For simplicity, I'm trying to just print the Owner field in this example:



var PersonOwner = '{!Person.Owner__c}';

alert(PersonOwner+" is the owner!");



The error message I get when trying to save is:


Error: Field Person.Owner__c does not exist. Check spelling.
Same thing happens when I use just "Owner" without the __c.



What am I doing wrong?  Thank you!