写一个在ls代理中调用方法,并且通过方法得到返回值的项目实例:
----------------------代理-----------------------
Sub Initialize
Dim session As New NotesSession
Dim doc As NotesDocument
Set doc = session.DocumentContext
Dim Usename As String
'调用getUseName方法,传值为doc.read_dbdw(0)
Usename = getUseName(doc.read_dbdw(0))
'下面打印的值是通过getUseName方法处理后返回的值
Msgbox Usename
End Sub
-----------------------下面是方法------------------
Function getUseName(companyname As String) As String
'根据ID读取子系统名称
On Error Goto errDO
Dim configDb As NotesDatabase
Dim configDoc As NotesDocument
Dim configDc As NotesDocumentCollection
Set configDb = New NotesDatabase("","xtpz.nsf")
query = "form='FormWeb_M_LR' & CompanyName ='" & companyname & "'"
Set configDc = configDb.Search(query,Nothing,0)
If configDc.Count>0 Then
Set configDoc = configDc.GetFirstDocument()
getUseName = configDoc.GetItemValue("UseName")(0)
Else
getUseName = ""
End If
Exit Function
errDO:
Msgbox "get error from agent [getCompanyName in Agent_transportDoc of dbgl.nsf]" & Error & "--on line--" & Erl
getUseName = ""
End Function