Examples: Search method

  1. This script uses @IsResponseDoc to get a collection of all the response documents in a database that were created or modified in the past month.
    Dim db As New NotesDatabase("Katmandu","somedocs.nsf")
    Dim collection As NotesDocumentCollection
    Dim dateTime As New NotesDateTime("")
    Call dateTime.SetNow
    Call dateTime.AdjustMonth(-1) 
    Set collection = db.Search("@IsResponseDoc",dateTime,0)
  2. This script uses @IsResponseDoc to get a collection of all the response documents in a database.
    Dim db As New NotesDatabase("Katmandu","somedocs.nsf")
    Dim collection As NotesDocumentCollection
    Set collection = db.Search("@IsResponseDoc",Nothing,0)
  3. This script reminds project participants of their due date by mailing them a Project document from a database. The ReminderDate item on each document is used to indicate when a reminder should be sent. The Search method gets all Project documents for which the ReminderDate item is set to today, mails the document, and updates the ReminderDate field to one week later.
    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim collection As NotesDocumentCollection
      Dim doc As NotesDocument
      Dim nextDateTime As NotesDateTime
      searchFormula$ = {Form = "Project" & ReminderDate = @Today}
      Set db = session.CurrentDatabase
      Set collection = db.Search(searchFormula$, Nothing,0)
      Set doc = collection.GetFirstDocument()
      Set nextDateTime = New NotesDateTime("Today")
      Call nextDateTime.AdjustDay(7)
      While Not(doc Is Nothing)
        Call doc.Send( True )
        Call doc.ReplaceItemValue("ReminderDate",  _
        nextDateTime.LSLocalTime )
        Call doc.Save( True, False )
        Set doc = collection.GetNextDocument(doc)
      Wend
    End Sub