You need to sign in to do that
Don't have an account?
OpportunityShare and INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY : SOLVED
Problem statement:
When APEX inserting OpportunityShare records, you get DML Exception: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY
Why does this happen?
The obvious reasons are:
- OpportunityShare.OpportunityId is for an invalid Opportunity (or not an opportunity at all)
- Running user doesn't have access to the Opportunity in OpportunityId
But if neither of these are the case...what else could it be?
ANSWER:
You can not insert OpportunityShare records for the current owner of the record. You'll need to modify the Apex code to see if the current owner is the same as OpportunityShare.UserOrGroupId. If it is, then don't insert. You can still create OpportunityTeamMember records for that user but not OpportunityShare. Who the current user is will depend if you are doing the OpportunityShare Dml statement in a before trigger, after trigger, VF controller, or API.
Although I haven't tested this, I presume the above applies to AccountShare and CaseShare objects as well.
All Answers
Came across exactly the same problem and you proactive post saved my day.
Thanks !!!