SHARE
TWEET

getAnyDoc

gunawantw Sep 9th, 2019 (edited) 124 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %REM
  2.     Function getAnyDoc
  3.     Description: Comments for Function
  4.     NSFAppstore.com
  5. %END REM
  6. Function getAnyDoc(strServerName As String,strDbName As String, strViewLookupName As String,strKey As String,exactMatch As boolean) As NotesDocument
  7.     Dim act As String
  8.     Dim errstr As String
  9.    
  10.     On Error GoTo errhandler
  11.    
  12.     act="function getAnyDoc started"
  13.     If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
  14.  
  15.     act="ServerName = " + strServerName + ". DbName = " + strDbName
  16.     If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
  17.    
  18.     act = "ViewName = " + strViewLookupName + ". key = " + strKey
  19.     If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
  20.  
  21.  
  22.     Dim ses As New NotesSession
  23.     Dim currdb As NotesDatabase
  24.     Set currdb = ses.currentdatabase
  25.    
  26.     Dim LookupDb As NotesDatabase
  27.     Set LookupDb = New NotesDatabase(strServerName,strDbName)
  28.    
  29.     If LookupDb.Isopen = False Then
  30.         act="sorry, can not open database " + strDbName + " at server " + strServerName
  31.         If GlobaldebugFlag Then Call doCreateLogError(GlobalLogProgramName,act)
  32.         GoTo keluar
  33.     End If
  34.    
  35.     Dim viewLookup As NotesView
  36.     Dim viewLookupName As String
  37.     viewLookupName = strViewLookupName
  38.     Set viewLookup = LookupDb.Getview(viewLookupName)
  39.    
  40.     act="opening view " + viewLookupName + " ..."
  41.     If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
  42.    
  43.     If viewLookup Is Nothing Then
  44.         errstr="view " + viewLookupName + " is not there?  " + currdb.Filepath + " on server " + currdb.Server
  45.         If GlobaldebugFlag Then Call doCreateLogError(GlobalLogProgramName,errstr)
  46.         GoTo keluar
  47.     End If
  48.    
  49.     Dim lookupDoc As NotesDocument
  50.     Set lookupDoc = viewLookup.Getdocumentbykey(strKey,exactMatch)
  51.    
  52.     If lookupDoc Is Nothing Then
  53.         act=strKey + " not found !"
  54.         If GlobaldebugFlag Then Call doCreateLogError(GlobalLogProgramName,act)
  55.         GoTo keluar
  56.        
  57.     Else
  58.         act=strKey + " found it!"
  59.         If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)       
  60.     End If
  61.    
  62.     Set getAnyDoc = lookupdoc
  63.    
  64.     act="function getAnyDoc completed"
  65.     If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
  66.    
  67. keluar:
  68.     Exit Function
  69.    
  70. errhandler:
  71.     errstr = "function getAnyDoc error found ...."  & Str(Err) & ": " & Error$ + " at line " + CStr(Erl)
  72.     Call doCreateLogError(GlobalLogProgramName,errstr)
  73.     'Print errstr$
  74.     Resume Next
  75.    
  76. End Function
  77.  
  78. ------------------------
  79. Sub Initialize
  80.     Dim act As String
  81.     Dim currentserver As String
  82.     Dim errstr As String
  83.    
  84.     Call initLogVariable
  85.     GlobalLogProgramName = "test\testLookupAnyDoc\"+getSessionId
  86.  
  87.     On Error GoTo errhandler
  88.  
  89.     'ambil config
  90.     Dim theConfig List As Variant
  91.     Call getConfig(theConfig)
  92.    
  93.     If theConfig("GlobalDebug") = 0 Then
  94.         GlobalDebugFlag = False
  95.     Else
  96.         GlobalDebugFlag = True
  97.     End If
  98.    
  99.     act="start."
  100.     If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
  101.    
  102.     Dim ses As New NotesSession
  103.     Dim doc As NotesDocument
  104.     Set doc = ses.Documentcontext
  105.    
  106.     Dim currdb As NotesDatabase
  107.     Set currdb = ses.Currentdatabase
  108.    
  109.     Dim strServerName As String
  110.     Dim strDbName As String
  111.     Dim strViewName As String
  112.     Dim strKey As string
  113.  
  114.     Dim xdoc As NotesDocument
  115.    
  116.     strKey = "Gunawan T Wicaksono/DOMINO"
  117.     strViewName = "($VIMPeople)"
  118.     strDbName = "names_fake1.nsf"
  119.     strServerName = currdb.Server
  120.    
  121.     Set xdoc = getAnyDoc(strServerName,strDbName,strViewName,strKey,true)
  122.    
  123.     If xdoc Is Nothing Then
  124.         act="document not found"
  125.         If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
  126.     Else
  127.         act="document found " + xdoc.FullName(0)
  128.         If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
  129.        
  130.     End If
  131.    
  132. keluar:
  133.     act="completed"
  134.     If GlobaldebugFlag Then Call doCreateLogAction(GlobalLogProgramName,act)
  135.    
  136.     Exit Sub
  137. errhandler:
  138.     errstr$ = "testLookupAnyDoc error found ...."  & Str(Err) & ": " & Error$ + " at line " + CStr(Erl)
  139.     Call doCreateLogError(GlobalLogProgramName,errstr$)
  140.     'Print errstr$
  141.     Call doCreateToastrError(errstr$)
  142.     Resume Next
  143.    
  144. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top