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
mackendw@gmail.commackendw@gmail.com 

setting AccountSharing on Account fires Exception INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

Testing a trigger that establishes account sharing rules via Apex.

 

Trigger logic is setting the AccountShare object values as follows:

 

                         AccountShare processorSharingRule = new AccountShare();
                         processorSharingRule.AccountId = acct.Id;
                        processorSharingRule.OpportunityAccessLevel = 'None';
                         processorSharingRule.CaseAccessLevel = 'Edit';
                        processorSharingRule.AccountAccessLevel = 'Edit';
                         processorSharingRule.UserOrGroupId = pdr_u.Id;
                         acctSharingRules.add(processorSharingRule);

 

Exception fires when this code executes:

 

                 if (acctSharingRules.size() > 0) {
                     upsert acctSharingRules;
                 }

 

I have output the values of the acct.Id and pdr_u.Id and both contain valid values.  So it looks to be a security

setup problem.

 

Account is setup: Private with Grant using Hierarchies

Opportunity is setup: Private with Grant using Hierarchies

Case is setup: Private with Grant using Hierarchies

 

2 roles being used:

 

- PDR/DSR setup to control which users can access/manage the above entities.  They are set Read Only.

 

Any idea what I might be missing here that is causing the exception??