SnTT.gifWhen you need to 'collect' the selected documents in a LotusScript agent (set op for 'Selected documents'),
you usually use the following:

Set collection = db.UnprocessedDocuments

I skip the obvious initial Dim's and Set's, as we all know them.

This works fine most of the time. I must say however that the 'name' of this property does not sound obvious for a newbie.
However, I had an issue today (yes, I know it's Saturday, but we, independent professionals, need to make a living every day of the week ;-),
when I called an agent from an action button on an embedded view.
The db.UnprocessedDocuments referred to the 'parent' document, not to the selected documents in the view. Very annoying.
Then I remembered a NotesUIView property 'Documents':
Set uiview = Workspace.CurrentView
Set collection = uiview.Documents

This time the collection was correctly filled
(from a regular view, as well as from an embedded view).

I hardly ever use this property, and I don't know why,
as it is very convenient (and aptly named).
Any SWOT (Strengths, Weaknesses, Opportunities, or Threats) using this solution ?

Updated: Thanks to Jens who commented that when there's no checkmark in front of the selected documents, uiview.documents return an empty collection. This can be solved by addding the following:
If collection.Count=0 Then
Set doc = db.GetDocumentByID(uiview.CaretNoteID) 'another valuable hardly known property
If Not (doc Is Nothing) Then Call collection.AddDocument(doc)
End If

Category:  Domino  Notes  Show-n-Tell Thursday  SnTT  | TechnoratiTechnorati: , , ,