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
sfdcdudesfdcdude 

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,
Pradeep
 
VICKY_SFDCVICKY_SFDC
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
sfdcdudesfdcdude
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.

Thanks,
Pradeep.p
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!
Regards,
Suraj Tripathi
sfdcdudesfdcdude
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.');
}
            
        }
    }

Thanks,
Pradeep.p
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.

Related:https://salesforce.stackexchange.com/questions/159644/how-can-we-give-permission-to-profile-users-to-delete-the-notes-and-attachments

Limiting ability to add or delete Attachments:https://trailblazers.salesforce.com/answers?id=90630000000D0LpAAK

If this information helps, please mark the answer as best. Thank you
sanket mahajan 1sanket mahajan 1
Hello,
Please refer the link:
https://sfdc-concepts.blogspot.com/2021/10/difference-between-delete-and-remove.html