« Finally, a Penalty for Incompetence | Main| Thanks for the Plug Bruce! »

Do you REALLY want to delete that Notes document?

Category


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:


A picture named M2

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:


A picture named M3

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

1 - First, I just noticed that the graphics in this post had been messed up so I have restored them.

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.

2 - What about %include "lssconst.lss" and starting using MB_YESNO instead of cryptic 6 ?

Your Host

KevinPettitt.jpg
Kevin Pettitt View Kevin Pettitt's profile on LinkedIn

Tools I Use

Idea Jam

Subscribe to This Blog

 Full Posts  Comments

MyYahoo
netvibes Add to Netvibes

Contact

Hosted by

OpenNTF

Disclaimer

This site is in no way affiliated, endorsed, sanctioned, supported, nor blessed by Lotus Software nor IBM Corporation, nor any of my past or future clients (although they are welcome to do so). The opinions, theories, facts, etc. presented here are my own and in no way represent any official pronouncement by me on behalf of any other entity.

© 2005-2017 Kevin Pettitt - all rights reserved as listed below.

Creative Commons License
Unless otherwise labeled by its originating author, the content found on this site is made available under the terms of an Attribution / NonCommercial / ShareAlike