Retain documents selection with LotusScript agent

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: Retain documents selection with LotusScript agent

Well, it is indeed impossible to checkmark a document via LS … wich is sad :frowning:

In one application I did it is way:

stamp the selected documents with a field value e.g. FIELD checked:=1;

use this field to determine the background color of the rows in the view. (or an icon column)

Now the user can see the selected doc’s as they are marked with a different backgound color.

leaving the view, or using a ‘deslect all’ action button empties the ‘checked’ fields on all documents.

There are however some disadvantages using this method:

In Large views, there can be a performance problem.

in replicated db’s, this can generate a lot of useless replication data. This can be prevented in the replication settings, though.

Subject: Retain documents selection with LotusScript agent

I know this is a very old thread, but thought I’d post a response just in case someone was looking for an easier solution.

The easiest way to accomplish this is to call the LS agent using a simple action.

In my experience, if you call the agent using ToolsRunMacro, the documents will be deselected once the agent has completed.

If you call the agent using a simple action, that document selection is retained.

Hope this helps someone out!

T.

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: Retain documents selection with LotusScript agent

Move your selected docs to a folder and then run your agents against the documents in the folder.

When you are done with a document, let the last agent also remove it from the folder.

Regards,

Chuck

http://www.csavino.com

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