Domino Code Fragment

Code Name*
Using UnprocessedDocuments to iterate through a view and , if the Approver item contains the current user's name, it sets the Approved item to "Yes."
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.118.150.80
Description*
This view action script allows a user to approve multiple requisitions at once by processing the currently selected documents in the Requisitions view. UnprocessedDocuments returns the documents 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."
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 Click(Source As Button)
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
For i = 1 To collection.Count
Set doc = collection.GetNthDocument( i )
Set item = doc.GetFirstItem( "Approver" )
If item.Contains( session.UserName ) Then
doc.Approved = "Yes"
Call doc.Save( False, True )
End If
Next
End Sub