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
Pranav S SanvatsarkarPranav S Sanvatsarkar 

OpportunityShare records are ready-only making the owner does not edit opportunity record

Hello there,

I am creating Opporotunity and Opportunity Team Member using API. While creating Opportunity Team member, an OpportunityShare record is getting created with OpportunityAccessLevel - Read-Only to the Opportunity, which is breaking some of my dependent functionalities. Though there are two OpportunityShare records - one with Full Access (Row Cause = Owner) and two - Read Only (Row Cause = Team).

I am not understanding as to how OpportunityShare with Access Level = Read Only is being considered instead of Opportunity Share with Access Level = Full ?

Thanks in advance.
VineetKumarVineetKumar
OpportunityShare table depicts the various sharing level that has been setup for your opporutnity record in salesforce:
As for your above scenario
  • Rowcause - Owner : This is giving Full Access on the opportunity record, for the record owner.
  • Rowcause - Team : This is giving the Read Only access to the opportunity record, for all the users setup-ed in the opportunity team.
Need you open up access:
you can do it by Apex, Manual, Profile/Role level.
Not sure what you are exactly looking for.
Pranav S SanvatsarkarPranav S Sanvatsarkar
Hi Vineet,

Thanks for your response.

Here is what I have done so far,
  • OWD for Opportunity is Private
  • I have communities set-up. External Sharing model is also Private for Opportunity.
  • Using communities, if a community user creates an Opportunity record, I am creating an OpportunityTeamMember record as well for some custom functionality.
  • As soon as I create, OpportunityTeamMember record, an OpportunityShare record is getting created with Row-cause - Sales Team. 
  • So, if I go to Opportunity -> Sharing I see three records,
    • Some User - Account ( Read-write - Owner of Account )
    • Community User - Owner ( Read-write - Owner of Opportunity )
    • Community User ( same as above ) - Sales Team ( Read-Only )
VineetKumarVineetKumar
Perhaps I didn't get your issue, your above comment itself is explaining what is the outcome.
Pranav S SanvatsarkarPranav S Sanvatsarkar
Hi Vineet, yes that's the outcome however it is not expected.

According to my understanding and document - https://developer.salesforce.com/docs/atlas.en-us.202.0.api.meta/api/sforce_api_objects_opportunityshare.htm?search_text=opportunityshare, 
  • If we have multiple OpportunityShare records with Row Cause
    • Manual
    • Owner
    • Team
  • Salesforce automatically merges records with above row causes into higher acess
    • If two records has Full Access and Read Only respectively, it should be merged into Full Access
    • If two records has Read/Write and Read Only respectively, it should be merged into Read/Wite
  • The above merging is not happenning, which is the issue that I am facing.
VineetKumarVineetKumar
Yes what you highlighted is correct, but you missed one important info.
If an opportunity is shared in multiple ways with a user, you don’t always see multiple sharing records. If a user has access to an opportunity for one or more of the following RowCause values, the records in the OpportunityShare object are compressed into one record with the highest level of access.

The sharing table records that you have shared, the sharing row is for different user.
  • Some User - Account ( Read-write - Owner of Account )
  • Community User - Owner ( Read-write - Owner of Opportunity )
  • Community User ( same as above ) - Sales Team ( Read-Only )
Get the userId's for the above highlighted users to analyze more closely
Pranav S SanvatsarkarPranav S Sanvatsarkar
Hi Vineet,

Here are OpportunityShare records with sample data,
  • User - Opportunity Access - Sharing Reason
  • Ajinkya - Read/Wite - Account Sharing
  • Pranav - Full Access - Owner
  • Pranav - Read Only - Sales Team
VineetKumarVineetKumar
Ok, so as per this - Ajinkya will have the full permission on the opportunity record, pranav will also have full permission on the opportunity record. Other users belonging to the sales team will have only read access to the record.
 
Pranav S SanvatsarkarPranav S Sanvatsarkar
Hey Vineet, you are right. However, if you see it closely, Pranav is the same user having two sharing records.Ending up on Read-only access.
VineetKumarVineetKumar
Ok, this shouldn't be the case though.. Since he is the owner, he will always have the full access.
Hope there is only one user with the name Pranav..