I want to select one or multiple documents in a view and set a value in a field for the document or documents selected. My code sets the value for all the documents not just the selected ones??
My Code:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView("Import")
Set doc = view.getFirstDocument
While (doc Is Nothing) = False
Call doc.ReplaceItemValue("Status", "Requires Validation")
Call doc.Save(True, True)
Set olddoc = doc
Set doc = view.getNextdocument(Doc)
Wend
It’s always more efficient to avoid looping if you can. The only time you’d need to loop to process selected documents is if you had conditional things to do - i.e. if the current document has a status of A, then set to B, otherwise set to C. But in your case, you’re applying the same value to all selected documents, so there’s no point in looking at each one individually.