Domino Code Fragment

Code Name*
Searching Notes Databases
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.12.161.161
Description*
Searching Notes Databases
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Exercise Title :

Where : PushButton or Form Action

Solution :

Sub Click(Source As Button)

'-- This script will perform searches of multiple Notes databases based on the criteria in the
'-- queryText field

'-- Get the Front and Back End Documents
Dim ws As New NotesUIWorkspace

Dim uidoc As Notesuidocument
Set uidoc = ws.CurrentDocument

Dim doc As NotesDocument
Set doc = uidoc.document

'-- Clear Current Found Value
doc.found = 0

'-- This array hold the names of the Notes DBs from which we search
Dim dbpath(2) As String
dbpath(0) = "PGN2\Newstand\news1.nsf"
dbpath(1) = "PGN2\Newstand\news2.nsf"
dbpath(2) = "PGN2\Newstand\news3.nsf"


'-- Search all databases, calculating the total matches
For i = 0 To 2

'-- Open the database and update the index
Dim db As New NotesDatabase("", dbpath(i) )

Call db.UpdateFTIndex(True)

'-- Perform the Full Text Search and track the number of matching documents

Dim collection As NotesDocumentCollection
Set collection = db.FTSearch(doc.QueryText(0), 0 )

matchCount = matchCount + collection.count

Next i

'-- Update Found field in Backend document as it is a Computed field and cannot be accessed via
'-- the front end document
Dim QueryDoc As NotesDocument
Set QueryDoc = uidoc.document
QueryDoc.found = matchCount

'-- Save Front End
Call uidoc.save

End Sub