I’m trying to insert Sharing records via apex for the object “SBQQ__Quote__Share”.
The class that inserts the record uses “without sharing”, but when i to insert the record i receive the error:
Insert failed. First exception on row 0; first error:
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access
rights on cross-reference id: []
This code works for other objects by the way..
i’m not adding the entire code as it is unnecessary, so here are the relevant parts:
public without sharing class OpportunityLookupsShareManager { public static void manageAccessToObject(sObjectType shareObject, sObjectType shareType,string oppFieldApiName, Map<String,Boolean> sharingMap) { Set<Id> opportunityIdSet = new Set<Id>(); List<SObject> objectList = new List<SObject>(); objectList = (List<SObject>)Type.forName('List<' + String.valueOf(shareObject) + '>').newInstance(); List<SObject> sharedToInsertList = new List<SObject>(); // ... Some logic here ... if (!sharedToInsertList.isEmpty()) { try { System.debug('sharedToInsertList: ' + sharedToInsertList); insert sharedToInsertList; } catch (DmlException ex) { system.debug(Logger.getException(ex)); Trigger.New.get(0).addError(ex); } } } }
}
in the debug logs i see:
sharedToInsertList: (SBQQ__Quote__Share:{AccessLevel=Edit, ParentId=a0x0Q0000002zwEQAQ, UserOrGroupId=00558000001ODmLAAW, RowCause=Manual})
Anyone knows what might cause the issue?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Dana Griff ,
This kind of error is basically coming due to sharing the inserted record back with the owner of the record who has full permissions on it already.
for reference:
1) https://developer.salesforce.com/forums/?id=906F00000008z1JIAQ
2) https://help.salesforce.com/articleView?id=000206576&type=1
4) INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference
hope it help you.
Method 2
You are trying to insert/updating the data in SBQQ__Quote__Share object. it seems, user dont have permission to access this object. could you please confirm the user access? please check the profile
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0