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[2. I probably could write an entire post just on DBAmp. It's a totally awesome product.].
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[3. Much rejoicing was had by all in this case...].
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.
i created a 'marketing' user in salesforce but they cannot add members to a campaign they created - it gives the 'insufficient priv's' error
ReplyDeletedo you know what i can do
@Christian... Take a look at this Answers post. It might be your solution: http://sforce.co/1JhMN8x
ReplyDeleteLet me know if it helps.
That was really excellent news to read
ReplyDeleteThat was great information to view that page
ReplyDelete