0

I have a requirement to remove the access for specific users, on the Delete case List View button. These users should still have Delete access on the Case object, in order to be able to merge cases. Also, these users are part of a team in which senior users and the manager should be able to have access to Delete Case button.

Does anyone have any idea about how can I do this? I've tried different approaches but neither of them worked as expected. One of them was to create custom permission and to check it the before delete trigger and add an error message with addError method, but that was also limiting the merge access.

Thanks in advance!

1 Answer 1

2

As far as a trigger goes, you can check in an after delete trigger if MasterRecordId is set, and if so, you know you have a merge on your hands:

trigger BlockDeleteButNotMerge on Case (after delete) {
  for(Case record: Trigger.old) {
    if(record.MasterRecordId == null) { // And any other conditions
      record.addError('You cannot delete this case.');
    }
  }
}

Note that merging requires Delete and Edit Case permissions, so you can't outright block deletes just from Profile Permissions. A trigger is likely the correct solution in this situation.

1
  • Man, again you save my life! Thank you so much...thanks for spending so much time helping noobs like me.
    – blanco17
    Commented May 24, 2022 at 9:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .