How To Fix Insufficient Access Rights On Cross-Reference Id?

15.2K    Asked by ananyaPawar in Salesforce , Asked on Nov 16, 2022

 I am getting the error:

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [] Scenario is, I am inserting an Opportunity and then Opportunity Line Item from a VisualForce page using controller. When I am doing this I am logged in as user whose profile license is "Authenticated Website". Strange thing is, when on another org logged in as user whose user profile license is Customer Portal Manager the same code work fine. Both orgs have Opportunity OWD "Read Only" and Opportunity line item "Controlled By Parent". To resolve this problem I've used "without sharing" on class which executes the insertion code, and it works fine from "Authenticated Website" user. As this may be a security issue when we try to list the app on AppExchange, is there any other way to resolve this problem?

Answered by Andrea Bailey
        INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross reference id is a common issue when you try to update or create data with insufficient access on a record. 

Kindly check the user profile and check whether the user has access to insert/update that record. Even if the user has access, kindly check whether the user has access to update fields like record types, lookup field, master-detail field, etc.

Troubleshooting steps:

Make sure whether the user has access to record ids of the lookup fields and/or master-detail fields in the record.

Check the user Profile(CRUD Permissions).

Profiles need to have access to the record types.

Record's OwnerId automatically gets a shared record when the record is inserted. If the apex code tries to create the same(Share record for the owner) explicitly. This error occurs.

Check whether the apex code is trying to create share records to the record in which the current user doesn't have access to it.

Note:

Even though trigger runs in System Mode, Sharing Settings will be checked. Only CRUD and FLS will not be checked against the user.
For further reference, you can check the below too,
https://help.salesforce.com/articleView?id=000328226&language=en_US&type=1&mode=1
https://salesforce.stackexchange.com/questions/5546/how-to-fix-insufficient-access-rights-on-cross-reference-id


Your Answer

Interviews

Parent Categories