You need to sign in to do that
Don't have an account?

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY when running TestMethod during install
In a testMethod, I have following code:
Account_Auditor__c Account_auditor = new Account_Auditor__c(Account__c = a.id, auditor__c = u.id, Audit_Type__c = 'Garbage');
insert Account_auditor;The intent is to execute the following trigger and give the "Auditor" read rights to the Account .
The testMethod runs fine in developer org, it croaks in the org that it is being installed it - it croaks on the Insert statement with the message:
caused by: System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id
trigger grantAuditorReadAccessToAccount on Account_Auditor__c (after insert) {
Account_Auditor__c[] Account_auditor_list = trigger.new;
for (Account_Auditor__c Account_auditor: Account_auditor_list) {
AccountShare ashare = new AccountShare();
ashare.AccountAccessLevel = 'Read';
ashare.OpportunityAccessLevel = 'None';
ashare.CaseAccessLevel = 'None';
ashare.AccountId = Account_auditor.Account__c;
ashare.UserorGroupId = Account_auditor.Auditor__c;
Insert ashare;
}
}
I suspect it has something to do with the user rights - I am fetching an active user from the database in the test method (u.id). In the org that I am installing, I have two users, one is system admin, another is a test user I created, so that i could install. I assume I am installing as a
Hope this helps.
All Answers
One other possibility - did you by chance set any access controls on the API when you uploaded the package? It's a setting on the package version.
However, I have only two users in my place where I am installing the Application. One is Admin. The other one does seem to have CRUD access to account, contact, opportunity and case (well no delete access on case).
No API restrictions.
I seemed to get around the problem by getting the Admin user instead of the first active user (i.e not getting the other user)
Hope this helps.
Hi,
I'm new to SF and my first assignment is to write Apex code for some requirements.
The scenario is complex but I'll try to simplify it like this:
Person X creates an Opportunity and changes the Owner to Y. But, X would still like to view the Opportunity. We know that whenever the Owner of a record is changed then all the sharing rules are deleted. So, I'm trying to write an Apex code in 'After Update' trigger of Opportunity to create a record in Opportunity_Share object with Parent Id = Opty Id and UserOrGroupId = X Id. But, I'm getting INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY error.
Because X is no more the owner of the record, I guess this error is shooting up.
Is there a way I can run the code as Admin which makes the Opty accessable all the time irrespective of who is modifying the Opty?
Thanks,
Nani.
Hi Nani,
Did u get the solution of your problem as i m facing the same issue. Please reply if you have any information on this.
Did you guys find any solution. Please reply..Thanks