function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CloudPower1CloudPower1 

Hide edit and delete button in standard detail page using jquery or Javascript

Hi ,

 

I am trying to hide standard edit/delete button from standard detail page.

 

I tried using Javascript and Jquery but none is working.

 

Javascript:

document.getElementsByName("edit").style.display='none';

 

Jquery:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$j = jQuery.noConflict();
$j(document).ready(function(){
$j("input[name=edit]").hide(); 
});

</script>

 

Please let me know if some thing needs to be changed in the above code, or let me know if any easy solution other than record types.

 

Thanks

Prashanth

Subramani_SFDCSubramani_SFDC

//Add jQuery from Google's secure servers
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

<script type="text/javascript">

//Prevent conflict between jQuery and salesforce scripts
$j = jQuery.noConflict();
//This function hides the [New] button from the related list in a specific tab
$j(document).ready(function hideButton(){
    //Get the current url
    var url = window.location.href;
    //Change the value of tabUrl with the URL of your tab
    var tabUrl = "https://cs10.salesforce.com/003/o";//This is my contacts tab url
    if(url.indexOf(tabUrl) !== -1){
        $j('[name="new"]').css({"visibility":"hidden"});
    }
  
});


</script>

GlynAGlynA

Prashanth,

 

Have you considered creating a security model that denies users the edit and delete permissions?  This will prevent the Edit and Delete buttons from appearring.  It will also prevent Edit and Del action links in list views.  This is probably the easiest way to do this, and it has the advantage of working for all record types of the object.  And you can give controlled access to certain users (and system administrators).

 

You could also edit the page layout to remove the Edit and Delete buttons.  This will need to be done for every record type of the object and in the future for any new records types.  This also doesn't prevent the Edit and Del action links in list views, so your users will have a way around the page layout.

 

Using JavaScript/JQuery seems like a difficult way to do this.  What exactly is your use case?  Are you trying to prevent certain users from editing/deleting records?

 

-Glyn