Examples: UpdateProcessedDoc method

This agent script is part of an agent that runs on newly created and modified documents since last run. The script gets the unprocessed documents in the current database, and marks each one as processed. For example, the first time the script runs, UnprocessedDocuments returns all of the documents in the database and UpdateProcessedDoc marks them all as processed.

The second time the script runs (and each time thereafter), UnprocessedDocuments returns those documents that UpdateProcessedDoc has not touched; for example, if three new documents have been added to the database and one existing document has been modified since the first time the agent ran, UnprocessedDocuments returns a collection of four documents.

Sub Initialize
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   Set db = session.CurrentDatabase
   Set collection = db.UnprocessedDocuments
   Set doc = collection.GetFirstDocument()
   While Not(doc Is Nothing)
     Call session.UpdateProcessedDoc( doc )
     Set doc = collection.GetNextDocument(doc)
   Wend
End Sub

For more examples, see the UnprocessedDocuments property, the UnprocessedFTSearch method, or the UnprocessedSearch method, in NotesDatabase.