+ Start a Discussion
Mounica M 10Mounica M 10 

Apex based sharing

I am salesforce administrator getting my hand dirty with development

In apex class, I am not able to set Accountshare.ContactAcessLevel to edit.

Error: Field is not writeable: AccountShare.ContactAccessLevel
OWD setting on account object is public read-only and contact is controlled by the parent.

Khan AnasKhan Anas (Salesforce Developers) 
Hi Mounica,

Greetings to you!

According to Salesforce doc:

Level of access that the User or Group has to contacts associated with the account. The possible values are:
  • None
  • Read
  • Edit
This field must be set to an access level that is at least equal to the organization’s default ContactAccessLevel. This field can't be updated via the API if the ContactAccessLevel field is set to “Controlled by Parent.” You can't update this field for the associated account owner using the API. You must update the account owner’s ContactAccessLevel via the Salesforce user interface

Note: When DefaultContactAccess is set to Controlled by Parent, you can’t create or update this field.

This field must be set to an access level that is at least equal to the organization’s default Account access level. In addition, the users’s AccountAccessLevel, ContactAccessLevel, OpportunityAccessLevel, or CaseAccessLevel field must be set higher than the organization’s default access level.

So, If your Contact sharing model is set to Controlled by Parent then you cannot set the ContactAccessLevel in AccountShare.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas
Mounica M 10Mounica M 10

@Khan Anas

Thank you for the quick reply.

so does it mean the if the user has AccountShareAcessLevel='Edit' he also gets ContactShareAcessLevel automatically because of OWD settings on contact?