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
Prasan6Prasan6 

Hide Upload Files button in Files Related List

Hi All, 
I am trying to hide the Upload Files button in the Files Related list. 
I want to force users to use Chatter Feed to upload files rather than use Upload Files option. 

Any workarounds? 

Regards,
Piyush Sharma 6Piyush Sharma 6
Since the upload Button is present on the related list, you have to Edit the layout of the parent object(which is having the related list).
In the Edit Layout, you can select the Related List Properties option and go to Buttons section.
From there you modify the settings for Upoad Files Button.
Prasan6Prasan6
Hi Piyush, 

Thanks for replying. 
You cannot remove "upload files" button from the Files related list. 

We could do this only by script. 
I want to us a vf page and onload of the page, I would like to hide the button. 
The code I have is as below but does not seem to work. Any ideas? 

<apex:page standardController="test__c">
  
    <script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
    <script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
    
    <script> 
    var previousOnload = window.onload; 
    window.onload = function() 
    {
        if (previousOnload) { previousOnload(); } 
        window.parent.document.getElementsById("RFLNewFile" )[0].style.display='hidden';
        alert('loading...'); 
        window.parent.document.getElementsByName("NewFile" )[0].style.display='hidden';
    } 
    </script>
</apex:page>
Piyush Sharma 6Piyush Sharma 6
Hi,

Yes, you are correct, it is standard related list and cannot be customized. We can remove the related list itself.
I am not sure about how javascript will work here but if you are using Notes and Attachment related list on a visualforce page you can try below code.
Attached button will not be visible.
<apex:relatedList subject="{!$CurrentPage.parameters.id}"  list="CombinedAttachments" >
   <apex:facet name="header"><table><tr><td class="pbTitle"><h3>Notes and Attachments</h3></td></tr></table></apex:facet>
   </apex:relatedList>