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
Sonal NaikSonal Naik 

How can I hide the Attach File button from Notes & Attachments related list?

I'am creating a custom button named "attach file"  on the contact detail page i want to hide the "attach File" button from the "Notes and Attachments" section in he related list
Quesn:How can I hide the Attach File button from Notes & Attachments related list?
Please help me out with this issue
Jagannatha Reddy BandaruJagannatha Reddy Bandaru
Hi Sonal,

we can't hide that attach file in notes and attachments,

but  we can overcome this problem with visualforce page.


Thanks,
Jagan
jagan.srit@gmail.com
Naveen Rahul 3Naveen Rahul 3

Sonal naik,

you can,but thats not  the best practice,because sf html may change without any notice.

create an component add that component to layout or detail page.

in the component write a  JS to hide that button.

Thanks

Naveen

@anilbathula@@anilbathula@
Hi Sonal Naik

Go through this link for the solution:-
http://salesforce.stackexchange.com/questions/13446/how-can-i-hide-the-attach-file-button-from-notes-attachments-related-list
But its not the best practice.

Thanks
Anil.B
SarfarajSarfaraj
Hi Sonal

Override the contact detail page with a VF. Here is one sample. You may need to customize it based on your specific requirement.
<apex:page standardController="Contact">
  <apex:detail relatedList="false" />
  <apex:relatedList list="Opportunities"/>
  
  <apex:form >
    <apex:pageBlock title="Notes & Attachments">
     <apex:pageBlockButtons location="top">
         <apex:commandButton value="New Note" action="{!URLFOR('/002/e?parent_id=' + $CurrentPage.parameters.Id + '&retURL=%2F' + $CurrentPage.parameters.Id)}"/>
     </apex:pageBlockButtons>
              <apex:variable value="{!0}" var="cnt"/>
    <apex:repeat value="{!Contact.NotesAndAttachments}" var="item"><apex:variable value="{!cnt+1}" var="cnt"/></apex:repeat>
    <apex:pageBlockTable value="{!Contact.NotesAndAttachments}" var="item" rendered="{!cnt > 0}">
        <apex:column headerValue="Action" styleClass="actionColumn">
              <apex:outputLink styleClass="actionLink" value="{!URLFOR('/' + item.id + '/e?retURL=' + $CurrentPage.parameters.Id)}">Edit</apex:outputLink>
              <apex:outputPanel > &nbsp;|&nbsp; </apex:outputPanel>
              <apex:commandLink styleClass="actionLink" action="{!URLFOR('/' + item.id + '/e?retURL=' + $CurrentPage.parameters.Id)}" onclick="return confirm('Are you Sure?');">Del</apex:commandlink>
        </apex:column>
        <apex:column headerValue="Type">{!if(item.isNote, 'Note', 'Attachment')}</apex:column>
        <apex:column headerValue="Name">
            <apex:outputLink value="{!URLFOR('/' + item.id + '?retURL=' + $CurrentPage.parameters.Id)}">
            {!item.Title}</apex:outputLink>
        </apex:column>
        <apex:column headerValue="Last Modified By" value="{!item.lastModifiedBy.Name}"/>
    </apex:pageBlockTable>
    <apex:outputText value="No records to display}" rendered="{!cnt = 0}"/>

    </apex:pageBlock> 
  </apex:form>
  
  <apex:relatedList list="Cases"/>
</apex:page>