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?