2

I trying to hide the 'New' button on Contacts page(https://na15.salesforce.com/003/o). I trying with the jQuery code:

<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://na15.salesforce.com/003/o";

alert('hello taburl is' +tabUrl);

if(url.indexOf(tabUrl) !== -1)

{

var newBtn = $j('[name="new"]');
newBtn.css({"white-space":"normal","display":"none"});

}
});
</script>

I have pasted this code at Home Page Components. but, it didn't worked.

3
  • 1
    That page requires authentication, I suggest you paste the relevant HTML here.
    – AyB
    May 28, 2014 at 11:00
  • @ICanHasKittenz There is no HTML file related to this script. Because, i'm writing this script on Contacts page of salesforce. However, you can check this at salesforce instance for more details.
    – Rv1
    May 28, 2014 at 11:05
  • I was talking about the HTML tag containing the name new. Anyways, you do not seem to be calling the hideButton(); function anywhere?
    – AyB
    May 28, 2014 at 11:22

2 Answers 2

1

You code seem fine. Two things to make sure: First custom sidebar components enabled on all pages. To do so go to :

Setup-> User Unterface -> Show Custom Sidebar Components on All Pages

Second make sure your layout is the right one (i.e. you added the component to the same layout which is set to your profile)

0
0

Please check whether the "newBtn" is undefined or it is having some value by using console.log(newBtn). You can also try using j('#new') if the button is having a unique ID

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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