You need to sign in to do that
Don't have an account?
Rick MacGuigan
how to prevent user from deleting a file attached to an object
I have a custom object using a Visualforce page with a related list for 'Files.' The File related list can contain a PDF version of the Visualforce page that is generated by the controller to memorialize content. If an executive reviews and comments on the Visualforce page and creates the PDF how can I prevent a File from being deleted by the owner of the custom object if certain fields are populated/updated by an executive reviewer ?
<apex:relatedList list="AttachedContentDocuments" id="FilesList" />
Are the reviews and comments from the Visualforce page stored on the same record where the other fields are populated / updated.
1. You may need an additional set of audit fields (hidden on the page layouts) which are updated by a Process Builder to track which fields changed and who changed them. If a PB does not work an Apex trigger will.
2. You can then write a before delete Apex trigger that checks for the following and use an addError() to restrict the deletion.
- The fields that were modified
- The user who modified the fields
Hope that helps.Please mark the thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.
All Answers
Are the reviews and comments from the Visualforce page stored on the same record where the other fields are populated / updated.
1. You may need an additional set of audit fields (hidden on the page layouts) which are updated by a Process Builder to track which fields changed and who changed them. If a PB does not work an Apex trigger will.
2. You can then write a before delete Apex trigger that checks for the following and use an addError() to restrict the deletion.
- The fields that were modified
- The user who modified the fields
Hope that helps.Please mark the thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.