You need to sign in to do that
Don't have an account?
sfdeveloper12
Getting an error while deleting a record.
Hello,
I am doing task where i want to delete share record but its giving me an error as shown below.
"Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, see Insufficient Privileges Errors."
Account {"Party_Sea_ID__c":8375,"Customer_Number__c":"C3092","Name":"VILLAGE JEWELRY OUTLET OF KANNAPOLIS, INC.","DBA_Name__c":"VILLAGE JEWELRY OUTLET OF KANNAPOLIS, INC.","Customer_Group_Id__c":"a0028000015lr7TAAQ","OwnerId":"00528000003iGolAAE","owner1__c":"00528000003iL8FAAU","Terms_Id__c":"a042800000oV26ZAAS","Default_Currency__c":"US DOLLARS","No_of_Doors__c":0,"NumberOfEmployees":0,"Store_Size__c":0,"Status__c":0,"Sales_Code__c":"NONE","RecordTypeId":"01228000000QbiM","Asset_Credit_Limit__c":0,"Memo_Credit_Limit__c":0,"Outstanding_A_R_Balance__c":0,"Outstanding_Memo_Balance__c":0} Delete_Share: execution of BeforeUpdate caused by: System.DmlException: Delete failed. First exception on row 0 with id 00r28000020WN31AAG; first error: DELETE_FAILED, cannot delete owner or rule share rows, id=00r28000020WN31: [] Trigger.Delete_Share: line 29, column 1
My trigger is as followed.
trigger Delete_Share on Account (before update) {
set<Id> AccountIDs = new Set<Id>();
for(Account a: trigger.new){
AccountIDs.add(a.id);
}
List<AccountShare> jobShares = new List<AccountShare>();
map<String,AccountShare>accountShareMap = new Map<String,AccountShare>();
for(AccountShare accShare : [select AccountId,UserOrGroupId from AccountShare where AccountId in :AccountIds])
{
accountShareMap.put(String.valueOf(accShare.UserOrGroupId),accShare);
}
for(Account a : trigger.new){
Account oldAccount = Trigger.OldMap.get(a.id);
if (a.owner1__c != null && a.owner1__c !=oldAccount.owner1__c) {
AccountShare accountRecord = accountShareMap.get(string.valueOf(oldAccount.owner1__c));
if (accountRecord != null)
jobShares.add(accountRecord);
}
}
if(jobShares.isEmpty() == false){
delete jobShares;
}
}
29th line is this : delete jobShares;
Please help me. i dont know why is this happening.
Thanks & Best Regards,
Utkarsha
I am doing task where i want to delete share record but its giving me an error as shown below.
"Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, see Insufficient Privileges Errors."
Account {"Party_Sea_ID__c":8375,"Customer_Number__c":"C3092","Name":"VILLAGE JEWELRY OUTLET OF KANNAPOLIS, INC.","DBA_Name__c":"VILLAGE JEWELRY OUTLET OF KANNAPOLIS, INC.","Customer_Group_Id__c":"a0028000015lr7TAAQ","OwnerId":"00528000003iGolAAE","owner1__c":"00528000003iL8FAAU","Terms_Id__c":"a042800000oV26ZAAS","Default_Currency__c":"US DOLLARS","No_of_Doors__c":0,"NumberOfEmployees":0,"Store_Size__c":0,"Status__c":0,"Sales_Code__c":"NONE","RecordTypeId":"01228000000QbiM","Asset_Credit_Limit__c":0,"Memo_Credit_Limit__c":0,"Outstanding_A_R_Balance__c":0,"Outstanding_Memo_Balance__c":0} Delete_Share: execution of BeforeUpdate caused by: System.DmlException: Delete failed. First exception on row 0 with id 00r28000020WN31AAG; first error: DELETE_FAILED, cannot delete owner or rule share rows, id=00r28000020WN31: [] Trigger.Delete_Share: line 29, column 1
My trigger is as followed.
trigger Delete_Share on Account (before update) {
set<Id> AccountIDs = new Set<Id>();
for(Account a: trigger.new){
AccountIDs.add(a.id);
}
List<AccountShare> jobShares = new List<AccountShare>();
map<String,AccountShare>accountShareMap = new Map<String,AccountShare>();
for(AccountShare accShare : [select AccountId,UserOrGroupId from AccountShare where AccountId in :AccountIds])
{
accountShareMap.put(String.valueOf(accShare.UserOrGroupId),accShare);
}
for(Account a : trigger.new){
Account oldAccount = Trigger.OldMap.get(a.id);
if (a.owner1__c != null && a.owner1__c !=oldAccount.owner1__c) {
AccountShare accountRecord = accountShareMap.get(string.valueOf(oldAccount.owner1__c));
if (accountRecord != null)
jobShares.add(accountRecord);
}
}
if(jobShares.isEmpty() == false){
delete jobShares;
}
}
29th line is this : delete jobShares;
Please help me. i dont know why is this happening.
Thanks & Best Regards,
Utkarsha
I believe the issue that you are having here is that you do not have permissions to DELETE records of this Object type. Your account has been restriced to I presume, read/write, but this does not mean that you are allowed to delete. You would need to get an administrator to enable your delete priveledges on this object type before you can use your trigger.
I hope this helps, Take care,
Luke
All Answers
I believe the issue that you are having here is that you do not have permissions to DELETE records of this Object type. Your account has been restriced to I presume, read/write, but this does not mean that you are allowed to delete. You would need to get an administrator to enable your delete priveledges on this object type before you can use your trigger.
I hope this helps, Take care,
Luke
Refer the below links:
https://salesforce.stackexchange.com/questions/9076/revoking-apex-managed-sharing-permission
https://developer.salesforce.com/forums/?id=906F000000096RzIAI
Can you please Let me know if it works or not and also If you face any problems!!!
If it works don't forget to mark this as a best answer!!!
Thanks,
Raj
thank you very much for resolving my issue.