例: GetDocumentByUNID method

  1. 次のエージェントは、現在のデータベース内のすべての返答文書の親文書を取得します。
    Sub Initialize
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim dc As NotesDocumentCollection
      Dim doc As NotesDocument, pdoc As NotesDocument
      Dim docSubj As String, pdocSubj As String
      Set db = s.CurrentDatabase
      Set dc = db.AllDocuments
      Set doc = dc.GetFirstDocument
      While Not(doc Is Nothing)
        If doc.IsResponse Then
          Set pdoc = _
          db.GetDocumentByUNID(doc.ParentDocumentUNID)
          docSubj = doc.Subject(0)
          pdocSubj = pdoc.Subject(0)
          Messagebox "Parent: " + pdocSubj,, docSubj
        End If
        Set doc = dc.GetNextDocument(doc)
      Wend
    End Sub
  2. 次のエージェントは、lsERR_NOTES_BAD_UNID の処理を示します。エラーを発生させるため、UNID は故意に変えてあります。
    %INCLUDE "lsxbeerr.lss"
    Sub Initialize
      On Error lsERR_NOTES_BAD_UNID Goto processError
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim dc As NotesDocumentCollection
      Dim doc As NotesDocument, pdoc As NotesDocument
      Dim docSubj As String, pdocSubj As String
      Dim badID As String
      Set db = s.CurrentDatabase
      Set dc = db.AllDocuments
      Set doc = dc.GetFirstDocument
      While Not(doc Is Nothing)
        If doc.IsResponse Then
          docSubj = doc.Subject(0)
          ' Deliberately munge UNID
          badID = "Z" & Right(doc.ParentDocumentUNID, 31)
          Set pdoc = db.GetDocumentByUNID(badID)
          pdocSubj = pdoc.Subject(0)
          Messagebox "Parent: " + pdocSubj,, docSubj
        End If
    getNextDocument:
        Set doc = dc.GetNextDocument(doc)
      Wend
      Exit Sub
    processError:
      Messagebox docSubj,, "Bad UNID for ..."
      Resume getNextDocument
    End Sub