例: Merge method (NotesDocumentCollection - LotusScript®)

この例では、この 1 ヵ月の間に製品を購入したか、サポートを要求したすべてのカスタマについて、カスタマサポートデータベースを検索し、そのカスタマの名前を画面に表示します。

Sub Click(Source As Button)
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Set db = session.CurrentDatabase
  Dim dc1 As NotesDocumentCollection
  Dim dc2 As NotesDocumentCollection
  Dim doc1 As NotesDocument
  Dim monthago As New NotesDateTime("")
  monthago.SetNow
  Call monthago.AdjustMonth(-1)
  
  ' Not the most efficient way to find all customers where LastSale
  ' or LastCall was < one month ago, but it's just an example.
  Dim searchFormula As String
  searchFormula = {Form = "Customer" & LastSale > [} & monthago.DateOnly & {]}
  Set dc1 = db.Search(searchFormula,Nothing, 0)
  searchFormula = {Form = "Customer" & LastCall > [} & monthago.DateOnly & {]}
  Set dc2 = db.Search(searchFormula,Nothing, 0)
  Call dc1.Merge(dc2)
  
  Set doc1 = dc1.getFirstDocument
  Dim message As String
  While Not doc1 Is Nothing
    message = message & {
} & doc1.GetItemValue( "CustName" )(0)
    Set doc1 = dc1.getNextDocument(doc1)
  Wend
  Messagebox Mid$(message, 2), MB_OK, "Customers active in the last month"
End Sub