im trying to delete a share on a custom field, using a profile that doesn't have permissions for it.
field: Order_Request__C
i'm receiving the following error:
System.DmlException: Delete failed. First exception on row 0 with id 02c5E00001RXlyMQAT; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []
That's the function that deletes the sharing:
private void removeOrderRequestShare(Map<Id, Set<Id>> orderRequestIdToUsersSetMap, String accsessLevel) {
List<Order_Request__Share> sharedToDropList = new List<Order_Request__Share>();
sharedToDropList = CustomSharedUtil.obtainOrderRequestShareToDrop(orderRequestIdToUsersSetMap, accsessLevel);
delete sharedToDropList;
}
That's CustomSharedUtil.obtainOrderRequestShareToDrop:
public static List<Order_Request__Share> obtainOrderRequestShareToDrop(Map<Id, Set<Id>> orderRequestIdToUsersSetMap, String accsessLevel) {
List<Order_Request__Share> sharedToDropList = new List<Order_Request__Share>();
Set<Id> usersIdSet = new Set<Id>();
for (Id orderRequestId_i : orderRequestIdToUsersSetMap.keySet()) {
usersIdSet.addAll(orderRequestIdToUsersSetMap.get(orderRequestId_i));
}
List<Order_Request__Share> tmpSharedList = [SELECT Id, ParentId, UserOrGroupId
FROM Order_Request__Share
WHERE ParentId IN: orderRequestIdToUsersSetMap.keySet() AND
UserOrGroupId IN: usersIdSet AND
AccessLevel =: accsessLevel];
if (!tmpSharedList.isEmpty()) {
for (Order_Request__Share share_i : tmpSharedList) {
if (orderRequestIdToUsersSetMap.containsKey(share_i.ParentId) && orderRequestIdToUsersSetMap.get(share_i.ParentId).contains(share_i.UserOrGroupId)) {
sharedToDropList.add(share_i);
}
}
}
System.debug('sharedToDropList: ' + sharedToDropList);
return sharedToDropList;
}
to fix it, i tried to add "without sharing" to the class, but it didnt work. This didn't work. i looked all over and ran out of ideas, please help.