Select documents in a view?

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

Subject: RE: Select documents in a view??

use unprocesseddocuments method… search in help for more details.

thanks

jana

http://www.dominodesigner.com

Subject: RE: Select documents in a view??

You’re making this harder than it has to be… if you’re applying the same value to all selected docs you don’t have to loop; just use StampAll:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim dc as NotesDocumentCollection

Set db = session.CurrentDatabase

Set dc = db.unprocesseddocuments

Call dc.StampAll(“Status”, “Requires Validation”)

No need to call Save or anything with StampAll.

Subject: RE: Select documents in a view??

Thanks

Is this more efficient?

Subject: RE: Select documents in a view??

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.

Subject: RE: Select documents in a view??

Thank you

Just what I was looking for.