0

Need the ability to prevent users in a profile to be able to merge contacts but prevent them from clicking on delete button from contact detail screen and from related lists.

In before delete event, I am unable to identify whether the record was from merge or delete operation.

1 Answer 1

1

I would not do this in a trigger. Instead:

  1. Create a VF page with a page action method to invoke a Contact Controller extension method deleteRedirect()
  2. If the running user's profile is not allowed to do deletes, redirect to a VF page that displays a pageMessage "Sorry, deletes not possible" plus a Cancel button that takes the user back to the Contact detail page
  3. If the running user's profile can delete the Contact, simply execute DML to delete and then redirect back to the value of retURL parameter.
  4. Override the standard Contact delete button with your new VF page

Or variations on the above

3
  • Thanks for an alternate approach, but I am looking for a non vf solution. Sep 1, 2015 at 13:16
  • Thanks for an alternate approach, but I am looking for a non vf solution. Sep 1, 2015 at 13:19
  • as Trigger operates at the database level, per Separation of Concerns, it should not have to be aware of context of invocation
    – cropredy
    Sep 1, 2015 at 22:43

You must log in to answer this question.

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