logo

Tip: Confirm All Destructive or Irreversible Actions

One of the (many) beauties of Lotus Notes is being able to quickly add an Agent to do almost any task. They get used (and abused!) all over the place.

Most of the databases I see are almost always littered with Agents written to perform one-off data-cleansing tasks, but are left hanging around waiting to do damage.

The other thing I always see is badly-named Agents whose purpose is not entirely clear from the name alone and a review of the code itself is needed in order to work out what it does.

The danger with badly-named Agents is that an unsuspecting user can click on them, merely "to see what it does". Or they may click it accidentally. If the actions performed by the agent are irreversible then this is a bad thing.

What I always try to do when writing these kind of Agents is having the following code right up at the top:

If MessageBox("This will delete ALL documents!!!! Are you sure?", _
        52, "Confirm") = 7 Then
                Exit sub
End If

Which gives us:

image

It doesn't take long and could save so, so much hassle in the long run.

The Java equivalent is:

int option = JOptionPane.showConfirmDialog(null, 
  "This will delete ALL documents!!!! Are you sure?", 
  "Confirm", 
  JOptionPane.YES_NO_OPTION,
  JOptionPane.WARNING_MESSAGE);

if (option == JOptionPane.NO_OPTION ) {
  return;
}

Which looks like this:

image

Always, always warn the user what they're about to do. They might well ignore the dialog message completely, but at least you can say you warned them...

Comments

  1. Add a few more exclamation points in there just to be sure. You can !never have enough of them.

      • avatar
      • Jake Howlett
      • Tue 20 Nov 2012 05:45 AM

      How about this:

      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      !!! This will delete all documents !!!!!!!!!!!

      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      Show the rest of this thread

    • avatar
    • Mike
    • Tue 20 Nov 2012 05:51 AM

    All based on the assumption that users read message boxes!

    So many times I've had users complain in this sort of situation and when I asked if they were prompted before it continued, they always say "Yeah..something popped up. I always click Yes without reading"

    They quickly see the sight of me grinning in a "I'm covered should this go to court" style :-)

      • avatar
      • Jake Howlett
      • Tue 20 Nov 2012 06:12 AM

      You could always make them have to enter some kind of captcha. In extreme cases (such as the above, which would delete all documents) we could use an InputBox with a prompt like "This will delete all documents, please type 'go ahead' in this space in order to continue". if they press ok it goes in to a loop until the captcha is passed. if they press cancel if exits.

      Show the rest of this thread

  2. Where possible I prefer an undo option and skip the modal confirmation.

    Here the inline notification that an action was performed provides an option to undo that action. This saved the user who knows what he/she is doing from having to click the confirmation, while still being save to use.

  3. I like to use a prompt box that, in order to confirm the act of destruction, requires the user to type in the MD5 hash of their first dogs name. If they never had a dog, they can use the base64 encoding of their own name. But they must enter it in binary.

  4. Surely a message stating: "All your base are belong to us!" should be plenty :D.

  5. Once upon a time, I created an agent of DESTRUCTION. It got me into such deep doo-doo that I vowed always, always to make agents have reversible effects.

    i.e. no more deletions, only soft deletions.

    i.e. change a field? Note the value of the oldfield into a backupfield whose item name includes a primitive timestamp.

    If I really need to do a quick and dirty one, then I set up the visibility of the agent to just myself, or a group to which I am sure not even power-users will belong to.

    • avatar
    • Tom Weeghmans
    • Wed 21 Nov 2012 01:55 AM

    I agree that it's good practice to add a prompt in such an agent. But additionaly I prefer to only allow someone with a [Super] role to access/run this type of agent.

  6. So to sum this up, put up an evil confirmation box that says.

    "Database is now empty, you deleted everything !"

    With buttons "Undo" and "Leave empty"

    Where "Undo" is a cancel and "Leave empty" is an OK. Because you did not run the deletions yet you just wanted some attention.

    1. Brilliant. I'll have to use that.

    • avatar
    • Emilio
    • Mon 26 Nov 2012 07:20 PM

    Sometimes the users can not have the right to delete documents , so I several times develop an agent with this:

    Field form:= form + " Deleted"

    It removes the document from the views without deletion.

    Simple and you easily can restore it.

    • avatar
    • Alastair
    • Fri 14 Dec 2012 08:57 AM

    I prefer the lesson learnt approach... :)

    "We deleted all the documents, is that what you wanted?" [Yes / No].

    User selects:

    Yes - then delete the docs

    No - pop up dialog.. "Luckily for you, we can save your bacon. Don't worry pop around to [enter developer name] with an undo fee of [enter suitable amount] and we will make sure you don't get fired (this time)."

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Tue 20 Nov 2012

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content