Domino Code Fragment

Code Name*
Using UnprocessedDocuments on all newly created and modified documents, to modify the Status item of each document it processes.
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.220.187.178
Description*
This agent script runs on all newly created and modified documents, and its purpose is to modify the Status item of each document it processes.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Using UpdateProcessedDoc For agents that run on new and modified documents, newly received mail documents, pasted documents, or newly modified documents, you must use the UpdateProcessedDoc method in NotesSession to mark each document as "processed," which ensures that a document gets processed by the agent only once (unless it's modified, mailed, or pasted again). If you do not call this method for each document, the agent processes the same documents the next time it runs. UpdateProcessedDoc marks a document as processed only for the particular agent from which it is called. Using UpdateProcessedDoc in one agent has no effect on the documents that another agent processes. In all other agents and view actions, UpdateProcessedDoc has no effect. View actions When used in a view action, UnprocessedDocuments returns the same documents as an agent that runs on selected documents.
Files/Graphics attachments (if applicable): Code:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim dateTime As NotesDateTime
Dim doc As NotesDocument
Dim j As Integer
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set dateTime = New NotesDateTime( "Today" )
For j = 1 To collection.Count
Set doc = collection.GetNthDocument( j )
doc.Status = "Processed by agent on " _
& dateTime.LocalTime
Call doc.Save( True, True )
Call session.UpdateProcessedDoc( doc )
Next
End Sub