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

Hide Delete option and remove from record option in notes and attachments

Hi Team,

How can we hide the below options for a user.? Please suggest.

User-added imageThanks,
Hi Pradeep,,

Go To page layout field of that object,,then scroll down in the Bottom,,,there you can see a field name as Notes & Attachement  ,,on the the is a symbol  ===> "--" llike this,,,click on that ,,,then save
,,,so it will be removed from Page

Mark my answer as best if its helped you
Hi Viskaskumar_sfdc,

I am not seeing any such options. I opened the content document object and saw in fields and relationships, I could not find any fiell. and also, I have clicked on Pagelayouts, i didn't find any page layout. Could you please provide screenshots for the solution you explaind above. so, that it would be helpful for me in resolving this.

Suraj Tripathi 47Suraj Tripathi 47
Hi Pradeep,
You can not remove the Delete button from the record option in notes and attachments but you can modify all permission from the user. Limit the user, assign some permissions to user like as Read and write in this case. user can't View All/Modify, you can disable the button functionality.

if you have any query please comment.
If you find your Solution then mark this as the best answer to close this question. 

Thank you!
Suraj Tripathi
Hi Suraj,

For that requirement I have went with below one, and in debug it is showing parent ID value as null. Please crct if i did something wrong.

public static void restrictDeleteFiles(list<ContentDocument> oldlistContentDocument) {
        for (ContentDocument cd : oldlistContentDocument ) {
            system.Debug('parent id is----'+cd.ParentId);
                if(cd.ParentId.getSObjectType().getDescribe().getName() == 'custom_object__c'){
                    cd.adderror('You Cannot delete a record once uploaded.');

SwethaSwetha (Salesforce Developers) 
HI Pradeep,
>Attachments will follow the same security as the parent record.
>A profile user's will able to delete attachments if they have attachment parent object delete access.
>Also profile user's must have read/write record level access of the parent object.


Limiting ability to add or delete Attachments:

If this information helps, please mark the answer as best. Thank you
sanket mahajan 1sanket mahajan 1
Please refer the link: