26

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.

0

10 Answers 10

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.

3
  • 2
    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, 2012 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. Sep 10, 2012 at 13:46
  • 1
    @Anup : I've added a js example. Sep 12, 2012 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>
1
  • 4
    In addition to Sfdc.onReady(function), you also have sfdcPage.appendToOnloadQueue(function) at your disposal.
    – Mark Pond
    May 28, 2013 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

0

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
0

In lightning, Go to Object Manager--> Search Layouts for Salesforce Classic-->Choose List View layout--> Edit -->uncheck New button

-1

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

1
  • This is not a button that person in post is talking about. This one is what you see after entering Opportunity tab before picking list view. Oct 6, 2020 at 10:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .