Suppress Default Prompt "Do you want to delete the 1 document from the database?"

I’ve posted this in in v8 forum, but haven’t yet gotten an answer. I created this to give the user an option of also deleting all documents related to the document they are deleting (via a UID field with a common value).- My form name is “Main”.

  • “UID” is a field I created which assigns all the common requests with the same unique ID to make finding all the related documents later much easier.

The code below almost works perfect. Related documents are found, they are deleted, view is refreshed and related documents are gone. But when closing the database I get the default prompt you get in all Notes databases when you try to exit a database and you have a document marked for deletion: “Do you want to delete the 1 document from the database?” FYI: It doesn’t matter whether I choose “Yes” or “No” to that default prompt since the documents are already gone. <— I just want to get rid of that message and all will be well, can anyone help? Here is my code I am using in the Querydocumentdelete of the Database Script:

Sub Querydocumentdelete(Source As NotesUIDatabase, Continue As Variant)

On Error GoTo errhand

Dim session As New NotesSession

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim resp As Integer

Dim prompt As String

Dim AssocDocs As NotesDocumentCollection

Dim db As NotesDatabase

Dim v As NotesView

Dim workspace As New NotesUIWorkspace

Dim tmpUID As Variant

Dim nextDoc As NotesDocument

Set db = session.CurrentDatabase

Set v = db.getview(“(AllRequestsByUID)”)

Set dc = Source.documents

Set doc = dc.getfirstdocument

’ Do following if trying to delete a “Main” request &

’ there are reoccurring documents associated with the selected

’ request. Otherwise, it’s an individual doc and they are free

’ to delete it without prompt.

If doc.form(0) <> “Main” Then Exit Sub

If doc.Reoccuring(0) <> “Yes” Then Exit Sub

tmpUID = doc.UID(0)

Set AssocDocs = v.getalldocumentsbykey(tmpUID)

prompt = “Do you want to also select all " & AssocDocs.count & " associated reoccurring dates for deletion?”

resp = MsgBox(prompt, 35, “Verify”)

If CStr(resp) = “2” Then 'If Cancel, dont do anything

continue = False

Exit Sub

ElseIf CStr(resp) = “6” Then 'If Yes, select all reoccurances and delete them

Call AssocDocs.RemoveAll(True) ’ remove the docs on the backend

Call workspace.ViewRefresh ’ show removed docs on frontend

Else

’ If No, only mark the selected document for deletion

End If

Exit Sub

errhand:

MsgBox "QueryDocumentDelete error at line " & Erl & Error

Exit Sub

End Sub

Subject: Don’t let the user delete, let the server do it.

We have an aversion to actually allowing document deletions - something about working in a highly regulated industry - so all of our apps include ‘remove’ functions which do nothing more than set a field to some flag value and the views then exclude them (Field Hide = “Hidden” for instance). We typically ask for the reason and log the user, date/time, reason.

In the few cases where deletion is allowed, we let the user hide the doc(s), then the server runs a scheduled agent to delete anything flagged as ‘hidden’. This acts like a soft delete and we can set the actual deletion routine to run nightly or weekly depending on how much time we want the user to recover from an oopsy.

HTH

Doug

Subject: RE: Don’t let the user delete, let the server do it.

I am doing exactly the same thing. My users do not have delete access to our databases, instead their “delete” action sets the field ‘flagDelete’ to “Yes”, and every night a server agent (with delete access) delete any document with that field set.

Subject: RE: Don’t let the user delete, let the server do it.

Thanks for the response. Are you doing your method from the “QueryDocumentDelete” script? Using your method it sounds like you have to put code in every view and use a special “Delete” action button instead of the delete key on the keyboard?

My challenges sound a little bit different than yours since I am looking at a single document and finding all related documents and then marking those using the delete key on the keyboard. Because I am using it in QuerryDocumentDelete, it works everywhere - even in new private views the employee creates without us knowing. No special code is inserted in any views. But to be clear, we freely allow deletion from this database, I just need that last prompt to go away. :slight_smile:

I am interested in hearing more about the intricacies of how your method works, and where your code is located. Thanks for the responses!

Subject: RE: Don’t let the user delete, let the server do it.

My method is not very complicated. Yes, every view selection formula contains this additional part:| flagDelete!=“Yes”

But that is not very hard to do.

Regarding private views, they should be avoided anyway. The users can’t normally create private views unless the designer of the application explicitly created views as “Private on first use”, which he/she should not do.

I then simply have an action button in each document I allow the users to delete. This button is a shared action (write it once, use it everywhere) containing (in my case) a few lines of Lotusscript that change the current document into edit mode if not already in edit mode, set the value of the field ‘flagDelete’ to “Yes”, saves the document and closes it (all using UI classes).

As long as you make sure you have the hidden ‘flagDelete’ field on every form where you put the action button, it should work everywhere.

No, it will not work if the users select documents in a view and press “Del” on the keyboard. But you can add another action button to the action bar in the views that delete the selected dopcument(s). That has the additional advantage that you can add code to prevent users from deleting documents they did not create, or any other restrictions you want to impose. Perhaps you want to prevent deletion of documents who are not in a particular status, or who have been created less than five days ago, or something.

Subject: RE: Don’t let the user delete, let the server do it.

Karl-Henry Martinsson; Thank you for your suggestion, however your requirements are different than mine resulting in a different solution that fits your needs, not mine.

My original question of how do I suppress the delete prompt still remains - or what is in my existing code that is causing the prompt?

Subject: Suppress Default Prompt “Do you want to delete the 1 document from the database?”

if you don’t remove the document set at this line in your code :

Set doc = dc.getfirstdocument

it’s only marked to be deleted, so you will have the message at database closing.

if you remove that document directly in the querydocumentdelete , normally, it will never prompt you.

Subject: RE: Suppress Default Prompt “Do you want to delete the 1 document from the database?”

Thanks!