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
SurjenduSurjendu 

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();
co.URL=data.getUrl();
insert co;

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

so

co.url__c

or

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.
SurjenduSurjendu
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'

so
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)
https://na1.salesforce.com/soap/wsdl.jsp?type=*




SurjenduSurjendu
Thanks Ron...was a rookie..so was struggling...but am learning fast...thanks...
jvolkovjvolkov
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
 
  leadA.name = '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
  leadA.name = 'Test Lead A';                    // populate required fields
  leadA.company = 'Acme, Inc.';                  // populate required fields
  leadA.status = 'Open';                         // populate required fields
  leadA.email = 'jonsmith@abc.com';              // populate email field
  leads.add( leadA );                            // add Lead A to list
   
  Lead leadB = new Lead();                       // create second lead object
  leadB.name = 'Test Lead B';                    // populate required fields
  leadB.company = 'XYZ Corp.';                   // populate required fields
  leadB.status = 'Open';                         // populate required fields 
  // leave email field null for Lead B 
  leadB.new_email__c = 'bobjones@gmail.com';     // 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
TCAdminTCAdmin
Hello jvolkov,

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

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:

 

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}

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!