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
hector.asp2hector.asp2 

Compile Error: Field is not writeable: Contact.Name at line

Hi All,

 

I got the following error

Compile Error: Field is not writeable: Contact.Name at line 66.....

Following is the code snippet

 

 

global class clsCustomWebService_MergeStdObject {

...................

...............

webService static String mergeContactStdObj (String MasterId, String Slave1Id, String Slave2Id)
{


..........//This statement works

List<Account> ls = new List<Account>{new Account(name='Acme Inc.'),new Account(name='Acme')};
insert ls;


................................


...............//This line generate the error

List<Contact> ls = new List<Contact>{new Contact(name='Classic Inc.'),new Contact(name='Classic')};
insert ls;



......................

}

.........................

}

 

The same fails for Lead too.

What I want to achieve is run the code example as given in the below mentioned link for Account, Lead and Contact.

Following is the ref documentation link

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_merge.htm

 

 

 

Thanks

Hector....

 

krishnagkrishnag

i wonder how this line works fine

 

 

   List<Account> ls = new List<Contact>{new Contact(name='Acme Inc.'),new Contact(name='Acme')};

 the mistake is right there how can make a list of account and instantiate contact. comment this line and run.

 

hector.asp2hector.asp2

Sorry, my mistake. I have corrected the statement. The Account object is accessible but Lead and Contact are not.