Domino Code Fragment

Code Name*
Move Orphan documents to Orphans Folder
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.136.97.64
Description*
Moves all Orphan Documents to a folder called Orphans
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Sub Initialize
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Set db = session.currentdatabase
    Dim doc As NotesDocument
    Dim Parentdoc As NotesDocument
    Dim collection As NotesDocumentCollection
    Dim dt As Variant
    Dim counter As Integer
   
    Set collection = db.alldocuments
    For x = 1 To collection.count
         Set doc = collection.GetNthDocument(x)
         If doc.Isresponse = True Then
              On Error  Resume Next  ' execution with the next statement.
              If Err = 4091 Then
                   Call doc.PutInFolder( "Orphans" )
                   Counter = Counter + 1
              End If
              Set Parentdoc = db.GetDocumentByUNID(doc.ParentDocumentUNID)
              If (ParentDoc.Responses Is Nothing) Then
                   Call doc.PutInFolder( "Orphans" )
                   Counter = Counter + 1
              End If
         End If
    Next x
    Messagebox (Str(Counter) & " Documents were found")
End Sub