Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %REM
- Function getAnyDoc
- Description: Comments for Function
- NSFAppstore.com
- %END REM
- Function getAnyDoc(strServerName As String,strDbName As String, strViewLookupName As String,strKey As String,exactMatch As boolean) As NotesDocument
- Dim act As String
- Dim errstr As String
- On Error GoTo errhandler
- act="function getAnyDoc started"
- If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
- act="ServerName = " + strServerName + ". DbName = " + strDbName
- If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
- act = "ViewName = " + strViewLookupName + ". key = " + strKey
- If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
- Dim ses As New NotesSession
- Dim currdb As NotesDatabase
- Set currdb = ses.currentdatabase
- Dim LookupDb As NotesDatabase
- Set LookupDb = New NotesDatabase(strServerName,strDbName)
- If LookupDb.Isopen = False Then
- act="sorry, can not open database " + strDbName + " at server " + strServerName
- If GlobaldebugFlag Then Call doCreateLogError(GlobalLogProgramName,act)
- GoTo keluar
- End If
- Dim viewLookup As NotesView
- Dim viewLookupName As String
- viewLookupName = strViewLookupName
- Set viewLookup = LookupDb.Getview(viewLookupName)
- act="opening view " + viewLookupName + " ..."
- If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
- If viewLookup Is Nothing Then
- errstr="view " + viewLookupName + " is not there? " + currdb.Filepath + " on server " + currdb.Server
- If GlobaldebugFlag Then Call doCreateLogError(GlobalLogProgramName,errstr)
- GoTo keluar
- End If
- Dim lookupDoc As NotesDocument
- Set lookupDoc = viewLookup.Getdocumentbykey(strKey,exactMatch)
- If lookupDoc Is Nothing Then
- act=strKey + " not found !"
- If GlobaldebugFlag Then Call doCreateLogError(GlobalLogProgramName,act)
- GoTo keluar
- Else
- act=strKey + " found it!"
- If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
- End If
- Set getAnyDoc = lookupdoc
- act="function getAnyDoc completed"
- If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
- keluar:
- Exit Function
- errhandler:
- errstr = "function getAnyDoc error found ...." & Str(Err) & ": " & Error$ + " at line " + CStr(Erl)
- Call doCreateLogError(GlobalLogProgramName,errstr)
- 'Print errstr$
- Resume Next
- End Function
- ------------------------
- Sub Initialize
- Dim act As String
- Dim currentserver As String
- Dim errstr As String
- Call initLogVariable
- GlobalLogProgramName = "test\testLookupAnyDoc\"+getSessionId
- On Error GoTo errhandler
- 'ambil config
- Dim theConfig List As Variant
- Call getConfig(theConfig)
- If theConfig("GlobalDebug") = 0 Then
- GlobalDebugFlag = False
- Else
- GlobalDebugFlag = True
- End If
- act="start."
- If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
- Dim ses As New NotesSession
- Dim doc As NotesDocument
- Set doc = ses.Documentcontext
- Dim currdb As NotesDatabase
- Set currdb = ses.Currentdatabase
- Dim strServerName As String
- Dim strDbName As String
- Dim strViewName As String
- Dim strKey As string
- Dim xdoc As NotesDocument
- strKey = "Gunawan T Wicaksono/DOMINO"
- strViewName = "($VIMPeople)"
- strDbName = "names_fake1.nsf"
- strServerName = currdb.Server
- Set xdoc = getAnyDoc(strServerName,strDbName,strViewName,strKey,true)
- If xdoc Is Nothing Then
- act="document not found"
- If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
- Else
- act="document found " + xdoc.FullName(0)
- If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
- End If
- keluar:
- act="completed"
- If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
- Exit Sub
- errhandler:
- errstr$ = "testLookupAnyDoc error found ...." & Str(Err) & ": " & Error$ + " at line " + CStr(Erl)
- Call doCreateLogError(GlobalLogProgramName,errstr$)
- 'Print errstr$
- Call doCreateToastrError(errstr$)
- Resume Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement