Salesforce.com | Hide Standard Buttons in 6 Steps

Steve —  8.6.2012 — 2 Comments

Salesforce Hide Buttons

I wanted to share a little bit of knowledge I was able to scrape together on how to hide standard buttons in Salesforce. You don’t need any special developer skills, but you do need to be an admin in your org to do what is in this post.

In my particular scenario, I wanted to hide the Data.com CLEAN button from non-Data.com licensed users as this would produce an error indicating insufficient privileges for them, which is a “no-no” in my book.

I took the steps from THIS POST and made some tweaks. Below is a bit more information about each step for those not familiar with the terminology contained in the original post.

STEP 1 | Gather required identifiers
You will need to gather some information about the buttons you want to hide. I use the old-fashioned “View Page Source” from the context menu in Firefox and then a CTRL+F to find the button code. I was looking for the unique identifier of the button (id or name) and once I had that, I could move on to finding the field in the User object that controls data.com user provisioning.

I used Eclipse’s schema browser to traverse the User fields until I found what I was looking for – UserPermissionsJigsawProspectingUser (Boolean) – in my case and once I had that, I could move on to STEP 2.

STEP 2 | Write your JavaScript/jQuery
With the identifiers in hand, you need to write some jQuery code and store it in a .js file.. I chose jQuery over the original use of straight JavaScript because:

  1. I know it (and love it)
  2. It has unparalleled cross-browser support (very important)

You could use JavaScript if that’s more comfortable, but I give you everything you need below, so why not use it 🙂

The first line references the jQuery CDN on Google

<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

The subsequent lines use the value of our User field to determine if we should hide the buttons and run the rest only after the page has been loaded:

<script language="javascript"> (function(){ 
if (!{!$User.UserPermissionsJigsawProspectingUser}){ 
$('input[name="DataDotComClean"]').css('display','none');
$('#gwt_jigsawsearchButton').css('display','none'); 
} 
})();
</script>

Put both of these elements into a .js file (in order as shown) and move on to STEP 3.

STEP 3 | Create a new document in Salesforce
Log into Salesforce (as an admin) and create a new document. Use the .js file you just created as the source of that document and name it and put it in a folder so you (and other admins) can recognize it in the list of documents.

Before you move on to STEP 4, record the ID of the document you just created (it’s in the URL).

STEP 4 | Create a new Home Page Component
In order for this code to run regardless of what page the user is on, include it as a sidebar Home Page Component:

  1. Click Your Name | Setup | Customize | Home | Home Page Components
  2. Click New
  3. Name it (again, something obvious) and choose HTML Area as the type and click
  4. Choose NARROW as the position and paste the following in the HTML area:
    <script type="text/javascript" src=”/servlet/servlet.FileDownload?file=01530000001OcDl”></script>

    NOTE: The file ID from STEP 3 should be put into the ID after the “file” parameter.

  5. Save the component

STEP 5 | Add the component to home page layout
We have everything we need to seal the deal and now it’s just a matter of adding it to the default home page layout:

  1. Click Your Name | Setup | Customize | Home | Home Page Layouts
  2. Edit the Default Layout and check the box next to your new component
  3. Position the new component at the bottom (it should be there by default)
  4. Click Save
STEP 6 | Test it

This is the moment of truth. Either edit your own profile or your test profile (yes, you should have one) and login as it to make sure the buttons are shown/hidden based on your criteria.

I hope this helps clear up how you might go about hiding standard buttons without creating multiple page layouts (may not solve your problem) or custom VisualForce pages (need development resources). I was surprised how easy it was and that it worked on the first try. I hope it does for you too!

2 responses to Salesforce.com | Hide Standard Buttons in 6 Steps

  1. hi i want to hide the save and new button for one standard object is it possible?

    • Hi Suren – I’m not sure and I haven’t tried this solution on Summer ’13, so I invite you to try the technique described and let us know what you see.

Leave a Reply

Text formatting is available via select HTML. <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

CommentLuv badge