I have implemented an apex method that prevents a certain profile (let's call it A profile) from being removed from a Collaboration Group. The apex code works fine but I don't know if there's a way to show a custom message after the user clicks the (x) icon (see screenshot below, besides the Manager word).

The code is simple, a method called in a before delete trigger on CollaborationGroupMember object checks the profile of the member to be deleted and should throw an error message if the member's profile is A. The problem is that using addError on User, CollaborationGroupMember or CollaborationGroup objects throws an exception sObject does not allow errors. And, as long as I know, I can't use a Visualforce page since that (x) button can't be replaced.

enter image description here

Thanks for your help.

  • 1
    Without code samples, I'm going to have to just take a guess...
    – sfdcfox
    Oct 5, 2015 at 15:51

1 Answer 1


You're using the wrong object and/or field. Here's code that I've just written up that proves it works:

trigger preventDelete on CollaborationGroupMember (before delete) {
    for(CollaborationGroupMember g: Trigger.old) {
        g.addError('You cannot delete me');

The page will display this error message correctly once the user accepts the initial attempt to remove the member.

You must log in to answer this question.

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