QueryCalc это событие формы. Вот код который повешан на это событие переносишь в отдельную функцию какой-нить библиотеки. И агентом вызываешь эту функцию для каждого документа из множества.
Могу ли я просто код QueryRecalc, вставить в агента:
Set Doc = Source.Document
Dim session As New NotesSession
Set session = New NotesSession
Set prodb = session.CurrentDatabase
Set proDoc = prodb.GetProfileDocument("SystemInformation")
PathToServer = proDoc.GetItemValue("PathToServerDbIS")(0)
PathToDB = proDoc.GetItemValue("PathToDbIS")(0)+proDoc.GetItemValue("NameOfDbIS")(0)
Set session = New NotesSession
If db Is Nothing Then Set db = session.GetDatabase(PathToServer, PathToDB)
If view Is Nothing Then Set view = db.GetView ("ContragentsForContracts" )
Dim Cworkspace As New NotesUIWorkspace
Set uidoc = Cworkspace.CurrentDocument
Set Cdoc = uidoc.Document
Set cLink = New NotesRichTextItem(Doc,"ContractPartiesLink")
Set OtherDoc = view.GetDocumentByKey(Doc.GetItemValue("ContractParties")(0), True)
If Not OtherDoc Is Nothing Then
Call Doc.ReplaceItemValue("ContractPartiesAccount", OtherDoc.GetItemValue("ContractPartyAccount")(0))
' Call CLink.AppendDocLink(doc,""+Doc.Subject(0),)
Call CLink.AppendText(" Уставные документы ")
Call CLink.AppendDocLink(OtherDoc,OtherDoc.Subject(0),)
End If
'Set the saveoptions so that the user is not prompted when the document closes.
cdoc.form = "Contract"
Cdoc.SaveOptions = "0"
Call Cdoc.Save (True, False,False)
DocUNID = Cdoc.UniversalID
'Close the document in the UI
Call uidoc.Close (True)
'Re-open the document in the UI
Set uidoc = CWorkspace.EditDocument(True, Cdoc)
Set CDocN= uidoc.Document
cdocN.saveOptions="1"