I received some questions if I could add the code in a sample DB. After going through some old projects I found the code that is related to this article ‘Deleting documents in a view via icons‘.
The logic is captured in a script library called ‘Control’.
Here is the Options settings:

And the Declarations:

Add a Sub Function with the following code:
Sub DeleteItem(db As NotesDatabase, Qdoc As notesdocument)
‘=======================================================================
‘ Deletes the selected document, in case of no similar responses,
‘ the parent category will also be deleted
‘=======================================================================
‘Delete
Dim docID As String
Dim docCat As String
docID = Qdoc.Tx_InheritedID(0)
docCat = Qdoc.Tx_ProjCategory(0)
Call Qdoc.Remove ( True )
Dim docCollection As NotesDocumentCollection
Dim selection As String
selection = |Form= “F-ProjDetails” & Tx_InheritedID=”| + docID + |” & Tx_ProjCategory=”| + docCat +|”|
Set docCollection = db.Search( selection, Nothing, 0 )
If docCollection.count=0 Then
selection = |Form= “F-ResponseCategory” & Tx_InheritedID=”| + docID + |” & Tx_ProjCategory=”| + docCat +|”|
Set docCollection = db.Search( selection, Nothing, 0 )
Dim deleteDoc As NotesDocument
Set deleteDoc = docCollection.GetFirstDocument
Call deleteDoc.Remove(True)
End If
Messagebox “Do not forget to update/refresh the projects view via the F9 button to see the deletion.”, 0, “Deletion completed”
‘Refresh view. (!) This is the view that contains the delete icon…
Set view = db.GetView(“v-projects”)
Call view.refresh
End Sub