Sunday, November 29, 2009

Can your users be trusted with delete capability?

It did not take me long to realize that something drastic needed to be done after we started getting accused of fielding applications that randomly deleted documents. Given what was involved with recovering these documents, it is probably the best code I have ever written in terms of cost savings. Consider what needed to be done when a user accidentally deleted a document from a 50 Gig database.

Step 1. Email to backup dude to create restore of said database.(typically 2 days until available)

Step 2. Be ready to change the replica ID of said restored database lest it replicates and causes more problems.

Step 3. Find document, copy to production, delete restored database.

Two people over two days and a lot of email in between because some users can't be trusted with delete capability. We tried turning on soft deletions but it could be several months before someone realized that someone has actually deleted something that should not have been and keeping soft deletions around for that long in the production database was not practical.

The answer to this problem was to create a "Recycle Bin" database and take away actual delete capability from everyone except developers. The code is simple really, it just renames the form to "deleted"+Form name and writes an entry to the audit trail so from the users perspective, they have deleted the document(s) just like they are used to but, it has really just fallen off of all the views that a user sees. Once a week, a scheduled agent moves these pseudo deleted docs to a Recycle Bin database for safe keeping and or recovery later. Go figure, we are no longer accused of writing code that randomly deletes documents and when someone asks "what happened to the report for abc company from 2005?" we can tell them who deleted it and when but, more importantly, we can restore that document in minutes rather than days and having to depend on the backup dude to create a 50 Gig restore. I can not tell you how much time and aggravation this has saved us.

4 comments:

  1. We've been doing exactly this for years, and it's been great. You can even give users an "Undelete" capability if you wish, and simply pull in anything that people want into a "Stuff that is Deleted" view and let them restore things from there.

    There's unfortunately a rare bug that surfaces if you're using the db property "Optimize Document Table Map" to speed up your views -- on occasion a doc might still appear in a view when it shouldn't.

    But generally speaking it's a great way to accomodate deletions.

    ReplyDelete
  2. Thanks Eric. We do have a Marked for Deletion view that has an action to restore but we reserve that for ouselves so can get an apprectiation for who the biggest offenders are in terms of accidentally deleting documents.

    ReplyDelete
  3. Great stuff Curt. It would be great if either you or Erik could post some version of that code to OpenNTF :-)

    ReplyDelete
  4. @Kevin - There's not much to post:

    FIELD Form := "deleted" + Form

    As long as your views look at the form field appropriately that's all you need. If you need to pull docs from folders too then you're better off using a script/java agent to find what folders it was in (stamp that on the doc as you change the form field) but it's just as simple.

    Then a "Deleted" view is as simple as:

    SELECT @Left(Form; 7) = "deleted"

    ReplyDelete