There are many a times where we want to remove few standard buttons from page layout, but there is no such option to remove such restricted buttons. Few such buttons are …
Following is a solution which will hide “Save & Send Invitation” button on New Event page
STEP1: JAVASCRIPT Code. Create a JS file with below code
function hideBtns()
{
if(document.getElementsByName(“sendEmail”)[0]!=null)
document.getElementsByName(“sendEmail”)[0].style.display = ‘none’;
if(document.getElementsByName(“sendEmail”)[1]!=null)
document.getElementsByName(“sendEmail”)[1].style.display = ‘none’;
}
if (window.addEventListener) {
window.addEventListener(“load”, hideBtns, false);
}
else if (window.attachEvent) {
window.attachEvent(“onload”, hideBtns);
}
STEP2: Upload the JS file as a DOCUMENT
STEP3: Create a Home Page Component of type (HTML Area)
<script src=”/servlet/servlet.FileDownload?file=01530000001OcDl”></script>
Here 01530000001OcDl is ID of document created in STEP2
STEP4: Add above created Home page component in your home page layout.
That’s it you are all set, now open New Event and add invitees, automatically the “Save & Send Invitation” button will disappear.
Please note : If you have some functionality which you want to work across all pages or on every form then navigate to Setup then go to Customize->User Interface, check “Show Custom Sidebar Components on All Pages” under the Sidebar section.
excited to see a solution Ive been looking for a while now…tried it carefully step by step, unfortunately save & send update button on events is still there after adding invitees…can you help please, what am I doing wrong?
followed steps, did not remove save&send update button on create events…what am I missing? pls help…
Yeah, this is working, great. I have used this to modify country field into picklist values rather than a free text field. See also this post on the community site.
http://community.salesforce.com/t5/Visualforce-Development/Modify-content-on-standard-new-edit-page-for-accounts/td-p/196319
I did follow through all the steps but save&send update button is still visible on event page for me…
any ideas?
Make sure all double-quotes and single-quotes are standard and not replaced like Word does. Best do this in Notepad.
When you create Home Page Component – make sure you select the Narrow (Left) Column radio-button. When pasting in the script ensure you ticked the Show HTML check-box before pasting. After saving, go back into the component html and check for strange characters. I found a few like %80%9D had been pasted in somehow. Just remove them and re-save.
There will always be the name of the component displayed in the side-menu. 🙁
Hi,
Thanks for your post.
I have custom object ‘Prestart_Checklist__c’.
Please tell me what should I replace instead of ‘sendEmail’ according to my custom object.
Hi,
I have a custom object Prestart_Cehcklist__c and I want to hide Save and New button while editing the records.
Please tell me what I need to replace in the above code.
Thanks,
Hi,
Thanks a lot…
It’s working nice, but my query is , if i deployed it to another org, will it work fine or we’ll need to do some changes? (means.. element’s ids may be different)
This is very helpful!
One big problem I am experiencing: “When Show Custom Sidebar Components on All Pages” IS checked related tables are not rendering on any record for any object. I used the exact same code as above.
Any thoughts?
Thanks!
Idea from : Jain Chirag.
Just if this helps who are struggling with this code.
1) Please make sure that when you are adding the script to Home page component. Check show html checkbox.
2) in the same context while adding this script then add this:
where cs4 stands for server on which your salseforce org resides.and 015P00000009IcW is your JS doc id.
This is awesome! I can’t get this to work however. When I try to paste the script above in the html area, it gets stripped out when I try to save the page. Any thoughts on why this is happening?
I would love to get this to work! I don’t know Java or HTML, but I think I’ve been following instructions exactly. But the button still appears. I’m having the same issue as Mia. I paste in with Show HTML checked and save. When I go back to edit, it has disappeared. Also, when I save the .js file from Notepad which encoding should be used?
Hi Chirag,
Thanks for the post. I implemented it in our Org. It works fine but the side effect is it prevents the hover over related list links on all the layout?
Any ideas??
Hi Chirag,
Your post does the job but it destroys existing onload events.
I created a modification that will keep the existing onload events as is. I removed the timeout too; the onload event will fire after all elements are loaded, so imho not necessary:
[code]
function hideBtns(){
if(document.getElementsByName(“sendEmail”)[0]!=null)
document.getElementsByName(“sendEmail”)[0].style.display = “none”;
if(document.getElementsByName(“sendEmail”)[1]!=null)
document.getElementsByName(“sendEmail”)[1].style.display = “none”;
}
if (window.addEventListener) {
window.addEventListener(“load”, hideBtns, false);
}
else if (window.attachEvent) {
window.attachEvent(“onload”, hideBtns);
}
[/code]
Thanks for sharing the initial solution!
Ronald
Hi Chirag,
Am trying to hide the private checkbox on the Notes & Attachments using javascript as Notes & Attachments is non-customizable
Can I get any help regarding the javascript code that have to be injected to do so. Its a urgent requirement.
Thanks in advance..
Regards
Nitin
@Nitin – Use something similar to below to hide private checkbox:
document.getElementById(‘IsPrivate’).style.display=’none’;
Thanks for the response Chirag..
But unfortunately that isn’t working for me. I followed the same steps as described at the starting of the document and replaced the if clauses with the above given code. But the private checkbox is still shown up on the screen. Would be great if you could help me out with this.
Thanks
Regards
Nitin
This script works but it kills the ability to double click a field on a page to edit it.
The loss of this feature is far worse than the benefit of hiding the send email button. Any idea on how to fix the code? I tried Ronald Klaassen’s code but still didn’t have any luck.
Thanks,
Sam.
@Sam
I guess you are not checking for your existing onload events and overriding it with this new JS.
Make sure you have following code,
function addLoadEvent(func) { //define a new function called addLoadEvent which takes in one param which should be function
var oldonload = window.onload; //assign window.onload event to variable oldonload
if (typeof window.onload != ‘function’) { //if window.onload is not a function, and thus has never been defined before elsewhere
window.onload = func; //assign ‘func’ to window.onload event. set the function you passed in as the onload function
} else { //if window.onload is a function – thus already defined, we dont want to overwrite it so we will..
window.onload = function() { //define a new onload function that does the following:
oldonload(); //do whatever the old onload function did
func(); //and then do whatever your new passed in function does
}
}
}
Yes I remember I had to handle the onload events, and @Ronald did pointed me to the same, but I couldn’t invest time to update the blog. Today with your comment I had to do the same (thanks for reminding). I’ve updated the main post to contain JS code which will respect existing onload events. Thank you Keshav & Ronald for that pointer.
hello all. current date 2/4/2014. i was having a problem getting this to work even after checking all the comments here. i am leaving this comment in the hopes that someone else can solve this issue. first and foremost, i used the javascript posted by Ronald Klaassen and not the javascript posted by Chirag Mehta. I’m not sure if there is a difference but I was able to get it to work with Ronald’s code. The key thing I found that was holding me back, when I was creating the home page component, i would use this text:
When I saved the component and then edited it, I would the text was saved as this instead:
For some reason, the component editor was adding extra quotation marks to the quotation marks that were already present. I changed the quotation marks to apostrophes. Here is the text I pasted in:
and after save I got the proper html:
I also made sure the “Show Html” checkbox was set BEFORE I pasted the text into the box. I also needed to make sure the component was a Narrow (Left) Component and not Wide.
Finally, I noticed some concerns in the comments with various standard salesforce functionality not working (inline editing and hover related lists not showing). My testing shows that inline editing still works and hover related list continue to show so I’m not sure if this is still a concern or not.
I hope this helps.
Hi Chirag,
The code is working perfectly. However when go in for inline edit on any field and cancel it, the buttons are visible as the home page component is not triggered.
Can you please help me on this issue…
how to hide the standard new button from the opportunity page (recent view opp page)
Hi Chirag,
After Summer 15 release, the above code is not working for me. Any ideas??
H Chirag, I have a related question- I can make this work on pagelayouts but if I want to do the same on “related list views” it works the first time because home page component is loaded, but when I change to another view, the button is back on because the home page component never runs. Any ideas?
Did you get an answer, I have similar question?
Solution to hide list buttons, exposing via Sidebar.
$( window).load(function () {
callfunction();
});
var observer = new MutationObserver(function() {
callfunction();
});
observer.observe(document, {
childList: true,
subtree: true,
attributes: false,
characterData: false,
});
function callfunction(){
console.log(‘in callfunction’);
var sid = getCookie(‘sid’);
var server = “https://” + window.location.host + “/services/Soap/u/33.0”;
sforce.connection.init(sid, server);
var currentUser = sforce.connection.getUserInfo();
var v=currentUser.profileId;
//use query to get profile name
if(!( (v.lastIndexOf(’00eXXXXXXXXX’, 0) === 0)) //check you profiles
{
if(document.getElementsByName(‘button_name’)[0] != undefined)
document.getElementsByName(‘button_name’)[0].style.display=’none’; //hide your buttons
}
}