Do you REALLY want to delete that Notes document?
Category Domino Tips
As a Notes developer, I sometimes find it necessary to add special features to some databases with unusual document deletion requirements. Maybe I'll need to play with Author fields to allow different users the ability to delete different types of documents. Or perhaps some sort of soft deletion approach is called for to allow database admins to "undelete" those documents in those instances where users "goofed".
But setting all such special cases aside, there is one piece of code that I like to put in virtually all my databases that adds an extra layer of protection against accidentally deleting documents using the CUT (Ctrl-X) command. Many Notes users have figured out that they can cut, copy, and paste documents simply by selecting them in views and using the familiar commands. But while Notes usually asks you to confirm deletions performed the normal way with the DELETE command, no such warning is given when you simply cut the documents from the view. Considering how easy it is to make an errant keystroke and not realize it, this behavior leaves your data extremely vulnerable to user error.
To address the problem, I pop up this warning anytime a user attempts to delete OR cut documents from a view:

The code to enable this is very simple, and is all contained in the QueryDocumentDelete event of the Database Script. For those not familiar with this aspect of a Notes database, here's where you will find the Database Script:

Open the Database Script, find the QueryDocumentDelete event, and then paste in this code:
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
'only need to present confirmation for those with delete rights
If UserHasRole("Administrators") = False Then Exit Sub
Dim flag As Integer
flag = Messagebox ( "Are you SURE you want to DELETE the selected Documents?", 4 + 32 + 256, "DELETION WARNING!")
If flag = 6 Then
'continue processing since user has chosen "YES"
Else 'flag = 7 'User has chosen "NO" so stop the process here
Continue = False
Exit Sub
End If
End Sub
Hope this helps. Next time I'll write about preventing users from pasting documents into a view when they shouldn't.
As a Notes developer, I sometimes find it necessary to add special features to some databases with unusual document deletion requirements. Maybe I'll need to play with Author fields to allow different users the ability to delete different types of documents. Or perhaps some sort of soft deletion approach is called for to allow database admins to "undelete" those documents in those instances where users "goofed".
But setting all such special cases aside, there is one piece of code that I like to put in virtually all my databases that adds an extra layer of protection against accidentally deleting documents using the CUT (Ctrl-X) command. Many Notes users have figured out that they can cut, copy, and paste documents simply by selecting them in views and using the familiar commands. But while Notes usually asks you to confirm deletions performed the normal way with the DELETE command, no such warning is given when you simply cut the documents from the view. Considering how easy it is to make an errant keystroke and not realize it, this behavior leaves your data extremely vulnerable to user error.
To address the problem, I pop up this warning anytime a user attempts to delete OR cut documents from a view:
The code to enable this is very simple, and is all contained in the QueryDocumentDelete event of the Database Script. For those not familiar with this aspect of a Notes database, here's where you will find the Database Script:
Open the Database Script, find the QueryDocumentDelete event, and then paste in this code:
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
'only need to present confirmation for those with delete rights
If UserHasRole("Administrators") = False Then Exit Sub
Dim flag As Integer
flag = Messagebox ( "Are you SURE you want to DELETE the selected Documents?", 4 + 32 + 256, "DELETION WARNING!")
If flag = 6 Then
'continue processing since user has chosen "YES"
Else 'flag = 7 'User has chosen "NO" so stop the process here
Continue = False
Exit Sub
End If
End Sub
Hope this helps. Next time I'll write about preventing users from pasting documents into a view when they shouldn't.


- 


Comments
As for your question, sure you could use the lssconst.lss and thereby improve the readabilty of the code. I simply never got into that habit but instead made sure to comment the code appropriately. It'll work either way.
Posted by Kevin Pettitt At 11:41:43 PM On 02/23/2006 | - Website - |
Posted by Rafal At 06:01:19 AM On 02/23/2006 | - Website - |