You need to sign in to do that
Don't have an account?
Apoorva Sharma
Delete failed. First exception : DELETE_FAILED, cannot delete owner or rule share rows
Hi All,
I am trying to Programmatically delete Sharing Rules with Apex. I am getting the following exception cannot delete owner or rule share rows. Below is my code:
public static void RestrictShare(List<Account> slist){
List<ID> shareIdsToDelete = new List<ID>();
for (Approval_Stage__c stage:slist) {
if (stage.Share__c == false) {
shareIdsToDelete.add(stage.id);
}
}
if (!shareIdsToDelete.isEmpty()){
delete [select id from AccountShare where AccountShare.Id IN :shareIdsToDelete];
}
}
I am calling it in a after update trigger
I am trying to Programmatically delete Sharing Rules with Apex. I am getting the following exception cannot delete owner or rule share rows. Below is my code:
public static void RestrictShare(List<Account> slist){
List<ID> shareIdsToDelete = new List<ID>();
for (Approval_Stage__c stage:slist) {
if (stage.Share__c == false) {
shareIdsToDelete.add(stage.id);
}
}
if (!shareIdsToDelete.isEmpty()){
delete [select id from AccountShare where AccountShare.Id IN :shareIdsToDelete];
}
}
I am calling it in a after update trigger
It seems that you have to delete the object record while deleting share records for that object.
Have a look at http://salesforce.stackexchange.com/questions/9076/revoking-apex-managed-sharing-permission.
Hope this helps,
Fred
If these answers helped you solve your problem, please, mark the question as Solved and kindly select the best one ;)
Thanks,
Fred
to the query of share objects.
Thanks for your answer.