You need to sign in to do that
Don't have an account?
SFDC Devl
How to hide save and new button on the edit page of a custom object
Hi,
I want to remove "Save & New" button on a custom object. I created a home page component and gave this (<script src="015Z0000000FJf7" type="text/javascript"></script>) in the body of the component.
I have placed this component on my home pagelayout.
I have created a .js file with below and uploaded to salesforce in Documents. Gave this document id above on the home page component
window.onload = hideBtns;
function hideBtns()
{
this.bodyOnLoad();
if(document.getElementsByName("save_new")[0]!=null)
document.getElementsByName("save_new")[0].style.display = 'none';
if(document.getElementsByName("save_new")[1]!=null)
document.getElementsByName("save_new")[1].style.display = 'none';
}
It is not working for me. I am able to see the button. Am I missing something? How to make this work? Also how to remove the button on a single custom object and leave the button on all other objects. I would appreciate your help.
Thank you.
I want to remove "Save & New" button on a custom object. I created a home page component and gave this (<script src="015Z0000000FJf7" type="text/javascript"></script>) in the body of the component.
I have placed this component on my home pagelayout.
I have created a .js file with below and uploaded to salesforce in Documents. Gave this document id above on the home page component
window.onload = hideBtns;
function hideBtns()
{
this.bodyOnLoad();
if(document.getElementsByName("save_new")[0]!=null)
document.getElementsByName("save_new")[0].style.display = 'none';
if(document.getElementsByName("save_new")[1]!=null)
document.getElementsByName("save_new")[1].style.display = 'none';
}
It is not working for me. I am able to see the button. Am I missing something? How to make this work? Also how to remove the button on a single custom object and leave the button on all other objects. I would appreciate your help.
Thank you.
You can add rerender attribute to show or hide button on specific condition. EX: rendered="{!IF(some condition, true , false)}".
For example refer: https://developer.salesforce.com/forums/ForumsMain?id=906F00000008lAeIAI
Please find the below code for hide save and new button.
<script>
function hideButton() {
var saveandNewid = document.getElementsByName('save_new');
var saveNewlen = saveandNewid.length;
for( var i=0; i< saveNewlen; i++)
saveandNewid[i].style.display = 'none';
}
window.onload = hideButton;
</script>
This is a working code..Please check.
You must need to add that home page component to the default home page layout.
Please let me know if u need any help.
This one still doesn’t work for me. I am sure I am missing something. I am listing down the details steps I followed.
1) Upload the document with below code into the “Documents” object folder – Document Id after uploading is 015Z0000000EICO
function hideButton() {
var saveandNewid = document.getElementsByName('save_new');
var saveNewlen = saveandNewid.length;
for( var i=0; i< saveNewlen; i++)
saveandNewid[i].style.display = 'none';
}
window.onload = hideButton;
2) Created New Home page component of Type “HTML Area” and Component position is “Narrow (Left) Column and the body has this code
<script src="015Z0000000EICO" type="text/javascript"></script> then saved the component
3) Added this component on the home page layout assigned to my system admin profile
4) Then clicked on the custom object tab and clicked on New, edit page is opened and I still see the “Save & New” button
Please let me know what did I miss?
Thank you.
Could you please post the final code on single object to remove "Save & New" button?
Thanks
function hideBtns()
{
this.bodyOnLoad();
var result = window.location.pathname.split('/');
if(result[1].substring(0,3) == 'XYX') //XYX is the sample custom object code. You can use your custom object index.
{
if(document.getElementsByName("save_new")[0]!=null)
document.getElementsByName("save_new")[0].style.display = 'none';
if(document.getElementsByName("save_new")[1]!=null)
document.getElementsByName("save_new")[1].style.display = 'none';
}
}
I saved the above code in a document in salesforce and I am using that Document Id on the home page component. I am using narrow left component. Don't forget to check the box "Show HTML" before pasting the below script.
<script src="/servlet/servlet.FileDownload?file=015G0000006IUwh" type="text/javascript"></script>
I hope this helps.
Thanks