我有一个具有以下代码的代理:
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 事件中运行的。
我现在已经像上面那样创建了一个代理,并且想从 ui 中以 lotus 脚本和@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
我将代理创建为触发器,事件 - 菜单选择,目标:无,选项:共享。我确实收到了“特工 Ran”消息框。
我已经尝试过了,但是虽然检查了它说它最后一次在onchange
事件触发时运行的代理,但我没有收到任何消息框或打印输出。
第一个问题,为什么消息框不工作?第二个问题是如何获取当前文档?