You need to sign in to do that
Don't have an account?
Spring 09: AccountContactRole.ContactId not writeable?
Hi all,
I'm seeing some differing behavior between our Winter sandbox and our Spring 09 sandbox. This snippet of code (from a testMethod) runs fine in Winter:
AccountContactRole acr = new AccountContactRole(); acr.ContactId = contact.Id; acr.AccountId = acct.Id; acr.Role = 'EC'; insert acr;
But in Spring 09, I get an error in the second line above stating "System.SObjectException: Field is not writeable: AccountContactRole.ContactId"
I see no mention in the release notes about Contact Roles changing. Is this not the correct way to create a contact role programmatically? Is this possibly a bug? Anyone else seeing this?
Jeremy Kraybill
Austin, TX
That is odd. It works fine for me in my dev (Spring 09) environment.
I ran this code in the execute anonymous and got no errors.
Account acct = [select id from Account where name='Test Acct' LIMIT 1]; Contact c = [select id from Contact where lastname='Tester' and firstname = 'Joe' LIMIT 1]; AccountContactRole acr = new AccountContactRole(); acr.ContactId = c.Id; acr.AccountId = acct.Id; acr.Role = 'EC'; insert acr;
Maybe it is an issue with your contact variable being named "contact". I have had scoping related issues due to this in the past.