A feature added in the Notes version 8.0 client but not much publicized, is the ability to perform a full-text search in a view using a Notes URL. This makes it simple to automate the creation of complex full-text searches for the user, perhaps based on information they enter in a dialog.
The URL syntax to perform the search is:
Notes://server/db/view?SearchView&query=yourQueryHere
There are no arguments to control stemming and sort order; these go to the defaults that the user last used. The server, db, and view components can be as usual for Notes URLs, and the query parameter must be escaped into valid URL characters. If the view is already open, the search occurs in the open view window.
The code below demonstrates how to create a search in this way based on information the user entered in a dialog:
Dim session As New NotesSession
Dim wksp As New NotesUIWorkspace
Dim db As NotesDatabase
Dim docDialog As NotesDocument
On Error Goto oops
Set db = session.CurrentDatabase
Set docDialog = db.CreateDocument
If wksp.DialogBox("searchAssistDialog", True, True, False, False, False, False, _
"Enter Search Criteria", docDialog, True, False, True) Then
Dim query, url$
query = Evaluate({ @URLEncode("Domino"; Query) }, docDialog)
url = "Notes://" + Replace(db.Server, "/", "%2f") + {/} _
+ db.ReplicaID + "/" _
+ wksp.CurrentView.View.UniversalID + {?SearchView&query=} + query(0)
Call wksp.URLOpen(url)
End If
Exit Sub
oops:
Msgbox "error " & Err & " line " & Erl & ": " & Error
Exit Sub
End Sub
The agent code assumes that the form used in the dialog (searchAssistDialog in this case) contains a computed field named Query that calculates the query you want to perform, based on the field values entered by the user. Coming up with this query string is the most difficult part of this project, but this is different in every case, so there's little I can say here to help you, except to point out an example in the "Student FT Search Dialog" form in the free download that accompanies this article: Views Part 1: User-Based Views and Query Assistant. The article describes other, harder ways of doing what we are now doing more simply using this new URL capability.
Of course, you could read the user's field values in the agent and calculate the query there, but I like an approach that lets you put everything that needs to know what fields are in the user assistant, into a single design element. If you prefer to use LotusScript to calculate the query, you could do it in the Queryclose event of the dialog form.
Note: the expression wksp.CurrentView.View.UniversalID doesn't work in desktop private views. You might want to modify this code to see whether wksp.CurrentView.View returns Nothing, and in that case use the view name or alias instead. In case the UNID is available, though, it's more reliable, since there may be duplicate view names or aliases.
Andre Guirard | 30 April 2009 06:00:00 AM ET | Caribou Coffee, Plymouth, MN, US | Comments (13)

