(Options) Option Public Option Declare (Declarations) Const wAPIModule = "NNOTES" ' Windows/32 Const NOTE_ADDED_TO_FILE = 13 Declare Private Function ConvertTIMEDATEToText Lib wAPIModule Alias "ConvertTIMEDATEToText" _ ( Byval zI As Long, Byval zT As Long, T As Long, Byval S As String, Byval nS As Integer, nT As Integer) As Integer Declare Private Function NSFDbOpen Lib wAPIModule Alias "NSFDbOpen" _ ( Byval P As String, hDB As Long) As Integer Declare Private Function NSFDbClose Lib wAPIModule Alias "NSFDbClose" _ ( Byval hDB As Long) As Integer Declare Private Function NSFNoteOpen Lib wAPIModule Alias "NSFNoteOpen" _ ( Byval hDB As Long, Byval NoteID As Long, Byval F As Integer, hNT As Long) As Integer Declare Private Function NSFNoteClose Lib wAPIModule Alias "NSFNoteClose" _ ( Byval hNT As Long) As Integer Declare Private Function NSFNoteGetInfo Lib wAPIModule Alias "NSFNoteGetInfo" _ ( Byval hNT As Long, Byval M As Integer, V As Any) As Integer Declare Private Function OSPathNetConstruct Lib wAPIModule Alias "OSPathNetConstruct" _ ( Byval zP As Long, Byval S As String, Byval F As String, Byval N As String) As Integer Sub Initialize ' this agent's job is to find all documents added to current replica of a "this" database ' once it finds them, it creates moves them to AddToThisFile folder in same database for review ' this agent should be added to the actual database replica with the documents to scan, after adding agent, create or copy the folder, too. ' 4/16/08 - Tripp Black, created for rep anomoly Dim s As New NotesSession Dim db As NotesDatabase ' current db Dim col As NotesDocumentCollection ' all docs in current db Dim doc As NotesDocument ' current doc being checked Dim todayNDT As NotesDateTime ' today used for comparison w/doc Dim docNDT As NotesDateTime ' the added to this file date of doc for current db replica Dim totalcount As Long ' total count of docs checked Dim putcount As Long ' count of docs put in folder On Error Goto ErrorHandler ' setup Set db = s.CurrentDatabase Set todayNDT = New NotesDateTime(Today) putcount=0 totalcount=0 ' get all docs Set col =db.AllDocuments Set doc = col.GetFirstDocument() While Not (doc Is Nothing) totalcount = totalcount + 1 ' check docs Set docNDT = New NotesDateTime(AddedToFile(doc)) If Not (docNDT Is Nothing) Then ' check date Print "(Initialize) Doc, " & doc.UniversalID & ", added: " & docNDT.DateOnly If (Strcompare(docNDT.DateOnly, todayNDT.DateOnly, 5) = 0) Then ' doc has same date, add to folder Call doc.PutInFolder("AddToThisFile",True) putcount = putcount + 1 End If End If ' loop NextDoc: Set docNDT = Nothing Set doc = col.GetNextDocument(doc) Wend Print "(Initialize) Done. Total count: " & Cstr(totalcount) & ", Put in folder count: " & Cstr(putcount) & "." Exit Sub ErrorHandler: Resume NextDoc End Sub Function AddedToFile(doc As NotesDocument) As String With doc.ParentDatabase Dim db As String Dim s As String Dim ns As Integer db$ = String$(1024, " ") OSPathNetConstruct 0, .Server, .FilePath, db$ End With Dim hDB As Long NSFDbOpen db$, hDB If hDB = 0 Then Exit Function Dim hNT As Long Dim T(1) As Long NSFNoteOpen hDB, Clng("&H" & doc.NoteID), 0, hNT If Not hNT = 0 Then NSFNoteGetInfo hNT, NOTE_ADDED_TO_FILE, T(0) NSFNoteClose hNT s$ = Space(80) ConvertTIMEDATEToText 0, 0, T(0), s$, 80, ns% AddedToFile = Left$(s$, ns%) ' return string w/added date End If NSFDbClose hDB End Function