Examples: UnprocessedDocuments property
- This agent script allows a user to approve multiple requisitions
at once by processing the currently selected documents in the Requisitions
view. UnprocessedDocuments returns the documents that are currently
selected in the view. The script iterates over each document and,
if the Approver item contains the current user's name, it sets the
Approved item to "Yes."
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) Set item = doc.GetFirstItem( "Approver" ) If item.Contains( session.UserName ) Then doc.Approved = "Yes" Call doc.Save( False, True ) End If Set doc = collection.GetNextDocument(doc) Wend End Sub
- 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.
- If the agent does not contain any searches and runs for the first time on October 17, 1995, UnprocessedDocuments returns all the documents in the database. The script puts "Processed by agent on 10/17/95" into the Status item of each document, saves the document, and marks it as processed. If the agent runs again the next day, and five documents have been created or modified since the 17th, UnprocessedDocuments returns only those five documents -- all other documents have been marked as processed -- and puts "Processed by agent on 10/18/95" into the Status item. If the agent runs again the next day, and one document has been created since the 18th, UnprocessedDocuments returns one document.
- If the agent does contain searches and runs for the first time
on October 17, 1995, UnprocessedDocuments returns all the documents
in the database that meet the search criteria. For example, it returns
all documents where the Subject field contains the word "Pablo." If
the agent runs again the next day, and five documents have been created
or modified since the 17th, but only two of them contain "Pablo" in
the Subject, UnprocessedDocuments returns those two documents. If
the agent runs again the next day, and one document has been created
since the 18th, but it does not contain "Pablo" in the Subject, UnprocessedDocuments
returns an empty NotesDocumentCollection.
Sub Initialize Dim session As New NotesSession Dim db As NotesDatabase Dim collection As NotesDocumentCollection Dim dateTime As NotesDateTime Dim doc As NotesDocument Set db = session.CurrentDatabase Set collection = db.UnprocessedDocuments Set dateTime = New NotesDateTime( "Today" ) Set doc = collection.GetFirstDocument() While Not(doc Is Nothing) doc.Status = "Processed by agent on "_ & dateTime.LocalTime Call doc.Save( True, True ) Call session.UpdateProcessedDoc( doc ) Set doc = collection.GetNextDocument(doc) Wend End Sub
- This agent script runs on all unread documents, and its purpose
is to put unread documents into a folder.
- If the agent does not contain a search, UnprocessedDocuments returns all unread documents in the database each time the agent runs, regardless of whether the agent has already run on some of the unread documents.
- If the agent does contain searches, UnprocessedDocuments returns
all unread documents in the database that meet the search criteria,
regardless of whether the agent has already run on some of the unread
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 doc.PutInFolder _ ( "Stop dreaming! Read these documents!",True ) Set doc = collection.GetNextDocument(doc) Wend End Sub