Deleting documents in a view via icons (code)

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:

viewicondelete01

And the Declarations:

viewicondelete02

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

Advertisements

4 thoughts on “Deleting documents in a view via icons (code)

  1. Stephan H. Wissel 2009-February-25 / 3:16 am

    Nice check for dependent documents. However… Every time you run the code a kitten dies. [vbg]
    Add “Option Declare” and they will live!
    🙂 stw

  2. louie 2013-June-28 / 4:49 am

    where is the COntrol socript library

  3. Patrick Kwinten 2013-June-28 / 8:32 am

    it’s in your face. look at the images above and recreate the script library yourself

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s