ApexINSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY: insufficient access rights on cross-reference id

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY: insufficient access rights on cross-reference id

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on crossreference 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

You can use userRecordAccess object to check CRUD permissions..

So pass the recordId and userId.. to check that user having what type of access on that record..

you can check variables like HasDeleteAccess. If HasDeleteAccess true means user have delete access. If false then user don’t have access..

Based on these accessibility perform DML..

List<UserRecordAccess> lstUserRecordAccess = [SELECT RecordId,MaxAccessLevel,HasAllAccess, 
                                                     HasDeleteAccess, 
                                                     HasEditAccess,
                                                     HasReadAccess, 
                                                     HasTransferAccess 
                                                FROM UserRecordAccess 
                                               WHERE UserId = '0036A00000uj2NY' 
                                                 AND RecordId = '0013u000017yqjK'];


Reference:

https://salesforce.stackexchange.com/questions/106212/insufficient-access-on-cross-reference-entity-insufficient-access-rights-on-cro

- Advertisement -spot_img

More From UrbanEdge

Top Salesforce Static Code Analysis Tools: Enhancing Code Quality and Security

#Heading1Introduction2What is Salesforce?3The Importance of Code Analysis4Understanding Static Code...

Trigger Challenge #12: Understanding the Trigger on Account and its Impact on Salesforce Development

As a Salesforce developer, understanding how triggers work is...

Best Practices for Apex Triggers

Introduction Apex Triggers are a fundamental aspect of Salesforce development,...

Why LWC was introduced?

Salesforce LWC: The Best Way to Create Customized User...
- Advertisement -spot_img