Video Success Tip 10 – How to Prevent Users from Accidentally Deleting Records in Salesforce

Back to Blog Home

It’s annoying and wastes valuable time when a user ‘accidentally’ deletes a record in Salesforce.  “I was sure I logged that call”, “No, that opportunity never existed”…. Would you like a way to avoid these conversations with your users and sales reps even if you’re using one of the lower/cheaper editions of Salesforce?

Well, you can stop wasting time now.  The video below shows you precisely what to do to stop users deleting records in Salesforce.  It’s very straightforward and all the steps you need to take are covered. So, within the next few minutes you can gain more control over the Delete button and avoid the problems of data disappearing through accidental deletions.

Beneath the video are the ‘code snippets’ that are referred to, all you need to do is highlight these, copy and paste them into your Salesforce organisation as described in the video.

If you hit any problems or would like us to do the fix for you – do get in touch by email, phone or Twitter

Good Luck and No More Accidental Deletions!

If you would like to find out how we can build bespoke solutions just for you, visit our Custom Development page. 

If this fix helped you – leave us a comment or send us a tweet!

Fix The Delete Button in Salesforce – Code Snippet for Accounts

Use this code on your “PreventAccountDelete’ Visualforce Page. Don’t forget to change the ‘Enter User Alias Here’ text for the alias of the person who is allowed to delete accounts.

<apex:page action="{!if($User.Alias !='Enter User Alias Here',
    null,
    urlFor($Action.Account.Delete, $CurrentPage.Parameters.id, [/fusion_builder_column][fusion_builder_column type="1_1" background_position="left top" background_color="" border_size="" border_color="" border_style="solid" spacing="yes" background_image="" background_repeat="no-repeat" padding="" margin_top="0px" margin_bottom="0px" class="" id="" animation_type="" animation_speed="0.3" animation_direction="left" hide_on_mobile="no" center_content="no" min_height="none"][retURL='/001'], true)
    )
    }"
  standardController="Account">
     <apex:pageBlock >
        <apex:PageMessage summary="You are not allowed to delete Accounts"
            severity="Warning"
            strength="3"/>
        <apex:pageMessages />
    </apex:pageBlock>
</apex:page>

 

Fix The Delete Button in Salesforce – Code Snippet for Contacts

Use this code on your “PreventContactDelete’ Visualforce Page. Don’t forget to change the ‘Enter User Alias Here’ text for the alias of the person who is allowed to delete contacts.

   
<apex:page action="{!if($User.Alias !='Enter User Alias Here',
 null,
    urlFor($Action.Contact.Delete, $CurrentPage.Parameters.id, [retURL='/003'], true)
    )
    }"
  standardController="Contact">
     <apex:pageBlock >
        <apex:PageMessage summary="You are not allowed to delete Contacts"
            severity="Warning"
            strength="3"/>
        <apex:pageMessages />
    </apex:pageBlock>
</apex:page>

 

Fix The Delete Button in Salesforce – Code Snippet for Tasks

Use this code on your “PreventTaskDelete’ Visualforce Page. Don’t forget to change the ‘Enter User Alias Here’ text for the alias of the person who is allowed to delete tasks.

<apex:page action="{!if($User.Alias !='Enter User Alias Here',
    null,
    urlFor($Action.Task.Delete, $CurrentPage.Parameters.id, [retURL='/00T'], true)
    )
    }"
  standardController="Task">
     <apex:pageBlock >
        <apex:PageMessage summary="You are not allowed to delete Tasks"
            severity="Warning"
            strength="3"/>
        <apex:pageMessages />
    </apex:pageBlock>
</apex:page>

 

Fix The Delete Button in Salesforce – Code Snippet for Opportunities

Use this code on your “PreventOpportunityDelete’ Visualforce Page. Don’t forget to change the ‘Enter User Alias Here’ text for the alias of the person who is allowed to delete opportunities.

<apex:page action="{!if($User.Alias !='Enter User Alias Here',
    null,
    urlFor($Action.Opportunity.Delete, $CurrentPage.Parameters.id, [retURL='/006'], true)
    )
    }"
  standardController="Opportunity">
     <apex:pageBlock >
        <apex:PageMessage summary="You are not allowed to delete Opportunities"
            severity="Warning"
            strength="3"/>
        <apex:pageMessages />
    </apex:pageBlock>
</apex:page>

 

Fix The Delete Button in Salesforce – Code Snippet for Leads

Use this code on your “PreventLeadDelete’ Visualforce Page. Don’t forget to change the ‘Enter User Alias Here’ text for the alias of the person who is allowed to delete leads.

<apex:page action="{!if($User.Alias !='Enter User Alias Here',
    null,
    urlFor($Action.Lead.Delete, $CurrentPage.Parameters.id, [retURL='/00Q'], true)
    )
    }"
  standardController="Lead">
     <apex:pageBlock >
        <apex:PageMessage summary="You are not allowed to delete Leads"
            severity="Warning"
            strength="3"/>
        <apex:pageMessages />
    </apex:pageBlock>
</apex:page>

These aren’t the only quick fixes we’re sharing for Salesforce. Check out The Apps Lab for more simple solutions to those daily, frustrating challenges you might face. 

How could the Cloud help your business and what other tips would you find useful?

Give us a call today on 0800 612 7699, send an email or a tweet!

Success Tips from CRM SuperStars

 

Marketing Automation launches made easy

‘LightningStart’ – your fast, effective route to an operational platform with both Pardot or Salesforce® Engage.

Need help with your successful Salesforce Implementation for your business?