The idea is fairly simple and I can’t seem to find a solution here or elsewhere so I’m hoping there is a workaround.
When a LotusScript agent is run on selected documents, the check mark selections is cleared automatically afterwards. There are times that I want to retain the selection so the user can run a different operation (agent) if so desired. For example, often we want to print labels and things may go wrong during print, so we leave it for the user to mark the print process is completed with a second agent. The desire goal is to have the user print as many time as s/he needs, and then use the second agent to mark the selected documents as ‘printed’. The only problem is that Notes automatically clear the selection after a run on selected doc agent is run. I can retain the selection when the first agent runs, but there is no way to have a LotusScript agent to go back and re-mark the selection. I can use uiview.SelectDocument, but that only moves the view cursor to that document, it does not check it. I’ve tried various tricks such as going through the OS level keyboard event call to simulate a pressing a spacebar, but I managed to only check only one document, not the rest.
Nothing seem to work so I’m wondering if this is even possible. I’d appreicated of suggestions or workarounds.
Subject: RE: Retain documents selection with LotusScript agent
Thanks a lot for that insight! I had the exact opposite problem that my selected documents always stayed selected while I didn’t want them to be. Now I know why.
Subject: RE: Retain documents selection with LotusScript agent
Moving them to a folder is not a problem, I can retain the doc selection list in a profile field and operate on them later on. However, the problem is that the check mark selection is no longer on the original and this workaround will require the user to deal with two visual items, a view and and a folder. It confuses end users and not a user-friendly solution.
Subject: Retain documents selection with LotusScript agent
I know this is an ancient question, but I thought I’d post my solution. Set your agent properties to a target of “None” instead of “All selected documents”, and use the following code. It uses CurrentView.Documents instead of UnprocessedDocuments if available, and falls back to processing the highlighted document if nothing is selected. If run in the background, it will use UnprocessedDocuments, and falls back to DocumentContext if it’s a “before new mail arrives” pre-delivery agent.
Dim ns As New Notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim collection As NotesDocumentCollection
Set db = ns.CurrentDatabase
If ns.IsOnServer Then
Set collection = db.UnprocessedDocuments
' No selected documents; try documentcontext
If collection.count = 0 Then
Call collection.AddDocument(ns.DocumentContext)
End If
Else
Dim uiws As New notesuiworkspace
' Unproc deselects all documents when accessed, so use currentview
' instead if possible
If (uiws.currentview Is Nothing) Then
Set collection = db.UnprocessedDocuments
Else
Set collection = uiws.CurrentView.Documents
End If
' No selected documents; just process the highlighted one
If collection.count = 0 Then
Call collection.AddDocument(db.GetDocumentByID(uiws.CurrentView.CaretNoteID))
End If
End If
' collection now contains the documents to process