How to delete the attachment with Validation?
I would like to perform validation before deleting an attachment in the "Attachment and Notes" detail in the Opportunity Section.
Step 1: A User (ex., Supervisor) is logging in and adding an attachment to the Opportunity record.
Step 2: On click of delete, there needs to be validation whether the user is in the same session on which the record is added, if he loggs out and logged in and tries to delete, it should not allow the user to delete, though the same user the session is different.
1.A user Logged in
2.A session ID is created for the user
3.User Adding an attachment to opportunity record
4.User tries to delete the record in same session (allows to delete)
5.Same User logs out and login, then tries to delete the attachment he added previously, now the attachment should not be deleted.
I Debugged to find out the below things,
Schema for Attachment & Notes : FileDetailV2
User & Session Table : SysUserSession
Delete method: onDeleted: function(record) in FileDetailV2 schema
please guide me to achieve the required validation