25

When you click on the Opportunities tab, (assuming you haven't modified standard salesforce layout), you see a "Recent Opportunities" list. At the top of the list, there is a "New" button.

enter image description here

Is there a way to hide the "New" button displayed on this page? I have tried disabling the button on the "Opportunity List View" Search Layout[Setup -> App Setup -> Opportunities -> Search Layouts], but it does not remove the button from this particular view.

  • If you found another way than the suggestions answered, you could add it as an answer yourself, so that the question does not remain open. – Samuel De Rycke Oct 10 '12 at 14:27
  • I have found a solution. Will post an answer soon. – Anup Oct 11 '12 at 16:46
  • @anup: what solution you found, can you post it? – Nick Kahn Aug 1 '17 at 15:38
10

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.

  • 1
    Well, we want them to create new opportunities but only via the "New Opportunity" button on the Opportunity related list on the Account or Contact page. It is more about streamlining process rather than restricting the act of creating opps. :) – Anup Sep 10 '12 at 13:41
  • Yea, those are the situations we use javascript for: in case it would fail in the future, there is no service disturbance or risk of things really turning ugly. – Samuel De Rycke Sep 10 '12 at 13:46
  • 1
    @Anup : I've added a js example. – Samuel De Rycke Sep 12 '12 at 8:32
12

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>
  • 4
    In addition to Sfdc.onReady(function), you also have sfdcPage.appendToOnloadQueue(function) at your disposal. – Mark Pond May 28 '13 at 22:07
5

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.

5

Try this app - just came up on a call today! I believe this would allow what you are asking to do.

https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B4AJKEA3

2

As per Summer 15 release this feature will break the functionality. Have a look at the following post. Javascript sidebar workaround Follow the steps mentioned in the post and upload a static resource file containing the following old school style javascript code. That should do the trick.

document.addEventListener('DOMContentLoaded', function () {
var url = window.location.href;
var tabUrl = "https://cs5.salesforce.com/006/o";
if(url.indexOf(tabUrl) !== -1){
    var x = document.getElementsByName("new");
    var i;
    var newBtn;
    for (i = 0; i < x.length; i++) {
        if (x[i].type == "button") {
            newBtn = x[i];
        }
    }
    newBtn.style.display = 'none';
}});
1

You can override the standard functionality of the 'New' button within the Button and Links section. Otherwise if memory severs correctly, if a person does not have access to create opportunities it will not display either

1

The new button is display if the User viewing the page has the create permission set in their profile for the object you are looking at.

Therefore I think that the only work around for this is to override the New button. SFDC documentation for how to do that is below

https://na5.salesforce.com/help/doc/en/links_customize_override.htm

1

You can hide the new Button from Opportuinity using this javascript in the Homepage component in the sidebar of the home page and just copy this code in the custom home page component.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script>$j = jQuery.noConflict();$j(document).ready(function hideButton(){var url = window.location.href;var tabUrl = "https://cs13.salesforce.com/006/o";if(url.indexOf(tabUrl) !== -1){var newBtn = $j('[name="new"]');newBtn.css({"white-space":"normal","display":"none"});}});</script>
0

You can do that by Clicking Search layout on Opportunity, there you can add your custom button and can remove new button by unchecking the check box.

Thanks Puneet Mishra

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.