Prevent Campaign Member Deletion

Jim Mitchell
Simply living simply
2 min readMay 26, 2015

--

We’ve begun integrating email blasts from Responsys into our Salesforce org at Lakeshore so our sales reps have better visibility into how their contacts are being marketed to.

If it weren’t for DBAmp from forceAmp, this might have been a really tough project… But, with the magic of a few SQL queries, I was able to get it working just the way we wanted it to.

But that’s not what this post is about.

One of the things I don’t like about the Salesforce Campaign/Campaign Member hierarchy is even though a user is granted Read Only permission on the Campaign object, they can still delete any Campaign Member for Leads or Contacts they have Read/Write access to, and there’s no real way to configure Salesforce to prevent it.

Here’s a simple hack I used to prevent Campaign Member deletion. Credit for it goes entirely to Chris Lance on the Success Community.

First, create a new Visualforce page that will be used to block Campaign Member deletion. The code below looks an awful lot like the standard Insufficient Privileges page a user gets when they’re not allowed to perform an action.

<apex:page standardController="CampaignMember" standardStylesheets="true">
<apex:form >
<table cellspacing="10">
<tr><td><span style="font-weight: bold; font-size: 12pt;">Insufficient Privileges</span></td></tr>
<tr><td>You do not have the level of access necessary to perform the operation you requested. Please contact your administrator if access is necessary.<br/></td></tr>
<tr><td><apex:commandLink action="{!cancel}" immediate="true" value="Return to previous page."/></td></tr>
</table>
</apex:form>
</apex:page>

Then, in the Campaign Member object (Setup > Build > Customize > Campaigns > Campaign Members > Buttons and Links), override the “Delete” button with the Visualforce page you just created.

Finally, rejoice that Campaign Members can no longer be deleted.

Of course, there is a limitation to this hack in that nobody can delete Campaign Members, even the System Administrator.

For our needs, this is fine since we’re integrating from an outside system. If certain profiles did need to delete, I might add some logic to the Visualforce page that lets them perform the action instead of being told they don’t have the privilege.

--

--

Jim Mitchell
Simply living simply

Family man. Minimalist. Nerd. Abuser of ellipses…but a nice guy otherwise.