例如:
parameterPassing 代理:
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim agent As NotesAgent
Dim doc As NotesDocument
Dim item As NotesItem
Dim paramid As String
Set db = ss.CurrentDatabase '得到要Run的代理的對象
Set agent = db.GetAgent("invokedAgent") '創建一份文件
Set doc = db.CreateDocument '將要傳遞的值賦給創建的文件中的
item Set item = doc.AppendItemValue("status","none")
Call doc.Save(True,False) '得到文件的NoteID
paramid = doc.NoteID 'Run代理
Call agent.Run(paramid) '將創建的文件在內存中刪除(即刪除文件的引用對象)
Delete doc '得到invokedAgent代理中保存的文件
Set doc = db.GetDocumentByID(paramid)
Set item = doc.GetFirstItem("status")
status = item.Text
Messagebox "status of invokedAgent = " & status '從磁盤上永久刪除此份文件
Call doc.Remove(True)
invokedAgent:
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim agent As NotesAgent
Dim doc As NotesDocument
Dim item As NotesItem
Dim noteID As String
Set db = ss.CurrentDatabase
Set agent = ss.CurrentAgent
noteID = agent.ParameterDocID '根據傳遞過來的參數noteID得到文件
Set doc = db.GetDocumentByID(noteID) '對文件中的item值進行操作
Set item = doc.ReplaceItemValue("status","OK")
Call doc.Save(True,False)
-----------------------------------------------------------------------------------------------------------------
以上就是一个简单的代理间参数传递。用RunOnServer方法进行参数传递和Run方法类似。