Loading

Error 'Field is not writeable: OpportunityTeamMember.OpportunityAccessLevel' on API insert of OpportunityTeamMember

Julkaisupäivä: May 1, 2026
Kuvaus

When creating Opportunity Team Members via the API in an org where Org Wide Defaults (the organization-level sharing settings) are set to Private for Opportunities, a compile error occurs:

COMPILE ERROR: Field is not writeable: OpportunityTeamMember.OpportunityAccessLevel

This error happens because the OpportunityTeamMember.OpportunityAccessLevel field is not editable through the API when Org Wide Defaults are configured as Private for Opportunities. In this configuration, Salesforce does not allow the access level to be set programmatically via the API.

This error can be avoided by removing references to OpportunityAccessLevel from any Apex code that inserts new OpportunityTeamMember records.

Ratkaisu

Solution: Omit the OpportunityAccessLevel Field:

OpportunityTeamMember records can still be created via API even when Org Wide Defaults are set to Private for Opportunities. The solution is to omit the OpportunityAccessLevel field from the Apex insert statement entirely.

Example: Successful Insert (Without OpportunityAccessLevel)

For example this code successfully creates a new Opportunity Team Member via API:

insert new opportunityteammember(OpportunityId='006000000000000AAD', TeamMemberRole='Account Manager', UserId='00500000000000OAA2');

Example: Failing Insert (With OpportunityAccessLevel)

This code returns the error because OpportunityAccessLevel is included in the apex insert statement.

insert new opportunityteammember(OpportunityAccessLevel='Edit', OpportunityId='006000000000000AAD', TeamMemberRole='Account Manager', UserId='00500000000000OAA2');

 

Lisäresurssit

OpportunityTeamMember

Knowledge-artikkelin numero

000384988

 
Ladataan
Salesforce Help | Article