Is it possible to remove/hide the "New" button?

I like Sdry's answer a lot, but there were two issues with it that I wanted to address:

  1. I don't want to include jQuery in a home page component.
  2. It doesn't work when the script runs before the element you are trying to hide is added to the dom. It really needs to be ran onDomReady.

So, after a bit of tinkering and finding out about Sfdc.onReady I came up with the following solution:

<script>
  Sfdc.onReady(function() {
    var keyPrefix = 'a7m';
    var toRemove = document.getElementsByName('new');
    if(document.location.href.indexOf('/' + keyPrefix + '/o') != -1 && toRemove && toRemove.length) {
      toRemove[0].style.display = 'none';
    }
  });
</script>

We use homepage components which analyse the page, and use javascript to remove/add buttons where we have no other choice to do so. But this implies developing with a high dependency on the salesforce html output .. which is not guaranteed to stay unchanged, this is something to strongly consider if you would explore this approach.

Why do you want to remove the new button ? If there are groups of users who should not make opportunities, you may want to restrict them access through their profile.

update: For instance, using jquery:

if (document.location.href.toString().indexOf("/a49/o") != -1) {
        $('input[name=new]').hide(); 
 }

You would need to update the Id when migrating code between sandboxes/organisations.


One sort of clunky workaround is to override the "New" function on the Opportunity object to redirect to a page that simply says, "Please create Opportunities from the Account Page" or something like that. This is probably the simplest way to keep them from using the standard New button, and just using your custom button on the Account Page.