Joshua Martin 11.Jun.09 01:54 PM a Web browser Domino Designer6.5.2 FP1Windows XP
Greetings - I have an agent that I run after selecting multiple documents in a view. This agent is in Formula. At the end of the agent I call a second LotusScript agent via @Command(ToolsRunMacro) that needs to also run on each of the documents selected.
However, when I run this, the second LotusScript agent (shown below) only runs on the first document selected. The purpose of the LS agent is to create DocLinks in the RTF of the selected documents.
I've tried replacing the While loop with If and I've tried it without the uiview.DeselectAll thinking that it might have deselected the documents after it ran on the first.
Dim uiview As NotesUIView
Dim dc As notesDocumentCollection
Dim doc1 As NotesDocument
Dim doc2 As NotesDocument 'must use two doc variables per IBM note regarding ADT error
Dim rtitem As NotesRichTextItem
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim workspace As New NotesUIWorkspace
Dim lookupdoc As NotesDocument
Dim polnum As String
Dim title As String
Dim varArray As Variant
Set uiview = workspace.CurrentView
Set dc = uiview.Documents ' Create collection of selected documents
Set doc1 = dc.GetFirstDocument ' Get the first document in the collection of selected docs
While Not (doc1 Is Nothing)
Set rtitem = New NotesRichTextItem( doc1, "AllCrossRefsNotes" )
Set db = session.CurrentDatabase
varArray = doc1.AllCrossRefDocIDs 'list of document ids for creating links to
Forall noteID In varArray 'loop through list of docids
Set lookupdoc = db.GetDocumentByUNID( noteID ) 'get a handle on the backend document
polnum = lookupdoc.PolicyNumber(0) 'get the policy number of the document
title$ = lookupdoc.Title(0) 'get the title of the document
Call rtitem.AppendDocLink( lookupdoc, "", polnum & " " & title) 'insert the link with policy number and title
Call rtitem.AddNewLine( 1 ) 'add a line after the link and loop back until end.
End Forall
Call doc1.Save (True, False) 'Save backend document
Set doc2 = dc.GetNextDocument(doc1)
Set doc1 = doc2