У меня есть агент со следующим кодом:
Sub Initialize
MessageBox "AgentStart"
Print "AgentStart"
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Dim vItemsBySupplierSpec As NotesView
Dim Doc As NotesDocument
Dim DocsWithSameSupplierSpec As NotesDocumentCollection
Dim MatchingDoc As NotesDocument
Set Doc = ws.CurrentDocument.Document
If Len(Doc.ItemSupplierSpecification(0)) > 0 Then
' Check that this supplier specification isn't use anywhere else.'
Set db = s.CurrentDatabase
Set vItemsBySupplierSpec = db.GetView("vItemsBySupplierSpec")
Set DocsWithSameSupplierSpec = vItemsBySupplierSpec.GetAllDocumentsByKey(Doc.ItemSupplierSpecification(0), True)
Set MatchingDoc = DocsWithSameSupplierSpec.GetFirstDocument
Dim ItemsString As String
ItemsString = "The following items already use this supplier specification." + Chr(10) + Chr(10) + _
"You should check whether you really want to raise another, or use the existing one." + Chr(10)
While Not MatchingDoc Is Nothing
ItemsString = ItemsString + Chr(10) + MatchingDoc.ItemNumber(0) + " - " + MatchingDoc.ItemDescription(0)
Set MatchingDoc = DocsWithSameSupplierSpec.GetNextDocument(MatchingDoc)
Wend
If DocsWithSameSupplierSpec.Count > 0 Then
Print ItemsString
MsgBox ItemsString
End If
End If
End Sub
Ранее он выполнялся в рамках события onchange поля в форме.
Теперь я создал агент, как указано выше, и хочу вызвать его из пользовательского интерфейса как в сценарии лотоса, так и на языке @formula.
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Dim CheckSupplierSpec As NotesAgent
Set CheckSupplierSpec = db.GetAgent("CheckSupplierSpec")
If CheckSupplierSpec.Run = 0 Then
MessageBox "Agent Ran"
End If
Я создал агент как триггер, по событию - выбор меню, цель: нет, параметры: общие. Я получаю окно сообщения "Агент Ран".
Однако я пробовал это, хотя, проверяя агента, он говорит, что последний раз запускался, когда было запущено событие onchange
, я не получаю никаких окон сообщений или вывода на печать.
Первый вопрос, почему не работает окно сообщений? второй вопрос, как я могу получить текущий документ?