+ Start a Discussion
Mary Anu 8Mary Anu 8 

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []: in apex trigger after insert

For system admin itself not working:
code:Trigger:
if(trigger.isafter && trigger.isinsert)
    {
        User_Case__Share userCaseShare=new User_Case__Share();
        User_case__c newUC=[SELECT Id, OwnerId FROM User_Case__c where id =:trigger.new];
        handler.shareUserCaseRec(newUC.Id,newUC.OwnerId);
    }

Hanlder class:
public class USRetail_StatusTypeChangeHandler {

    public void shareUserCaseRec(ID recordIDUC,ID UserOrGroupIdUC)
    {
         User_Case__Share userCaseShare=new User_Case__Share();
        userCaseShare.ParentId=recordIDUC;
        //userCaseShare.RowCause='Manual';
        userCaseShare.UserOrGroupId=UserOrGroupIdUC;
        userCaseShare.AccessLevel='Edit';
        insert userCaseShare;
    }
}
shailesh_rawteshailesh_rawte
Hi mary,


I would suggest checking the following:

Record Type Id specified is valid for your profile
You have create permission on Case object
You have read permission on Contact (specifically record '0033000000qYHOw')
User '00530000003sMR5' is active
Check your API Version is less than version 24.0. Later API versions will not give you access to org data by default. Consider creating records in the test method, or use annotation @isTest(SeeAllData=true) at the top of your test class.


Thanks
Shailesh Rawte
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Mary Anu,

May I suggest you please refer the below link for reference. Hope it helps.

Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.

Thanks
Rahul Kumar