即使我有一个分配给我的系统管理员配置文件,并且对Order Line Item对象具有CRUD权限,但当我试图通过我的Item类中的DML操作删除订单项记录时,我会收到以下错误。
System.DmlException: Delete failed. First exception on row 0 with id 8022M00000ANsKKQA1; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []为了避免与共享规则有关的任何冲突,我已经将Apex类写为,“不共享”。但我还是收到了这个错误。有人能告诉我为什么会发生这种事吗。我在更新触发器之后从调用这个类,我也使用同一个类插入客户历史记录。顶点类如下所示。
public without sharing class LineItemHistoryRecordCreation {
public LineItemHistoryRecordCreation() {}
public void createLineItemHistoryRecord(List<OrderItem> ordItemList) {
List<Id> oliIdList = new List<Id>();
List<History__c> historyList = new List<History__c>();
for(OrderItem oli : ordItemList) {
oliIdList.add(oli.Id);
History__c his = new History__c();
his.Change_Log__c = 'Order Product record deleted-OrderNumber ' + oli.OrderId + '-' + oli.Id + '-' + oli.OB_Order_ID__c;
his.History_Type__c = 'Order Product-Deleted';
his.History_DateTime__c = DateTime.now();
his.Record_Name__c = oli.Id;
his.Prior_Value__c = 'Active';
his.New_Value__c = 'Deleted';
historyList.add(his);
}
insert historyList;
List<OrderItem> oliList = [SELECT Id FROM OrderItem WHERE Id IN :oliIdList];
System.debug('order List akki' + oliList);
if(!oliList.isEmpty()) {
delete oliList;
}
}
}有人能帮我理解和解决这个问题吗?提前谢谢。
发布于 2021-06-23 12:46:57
https://stackoverflow.com/questions/68081928
复制相似问题