Customized Web Searching at Last!

Ever wonder the details and glitches of customizing FT searches? Let me help you out! Here's code to help you create a customized search form, search criteria, and search results without saving a document on the back end!
You can create a form from scratch calling it whatever you like. By default, Domino uses $Search (the search.htm file in the notes/data/domino/icons directory), but that one doesn't look too pretty. The form property "Treat Contents as HTML" does NOT need to be checked.

On your form, create the following text fields: Query(computed), $$Return(computed), SaveOptions(editable). All fields should have the lower 6 hide properties checked.

Place "0" in the value of SaveOptions. (This prevents Domino from making a document out of the search result.)

Inside $$Return place the following code:

path := @ReplaceSubstring(@Subset(@DbName; -1); ""; "/");
string := "?SearchView&Query=";
view:= "/<viewYouwantToSearch>/";
"[[/" +path+view+string+Query+"]]"

Now, what do you want to search on? The best way to retrieve accurate results for you users, is to give them the corresponding values of the fields to search on. (i.e. Subject with a dialog list that retrieves Subject values using DBLookup)

There are many ways to write a query string. For simplicity, we'll use 'AND' as our seperator. In this case presume our UI field is UIsubject, and on the document the field is fldSubject.

Place the following code into Query:

sep:= " AND ";
string:= @LeftBack(@If(UIsubject!="";"FIELD fldSubject=" +UIsubject+sep;""); sep);

You can do this for as many fields as you like that are on the document!

To complete it, create a button and place @Command([FileSave]);@Command([FileCloseWindow]) in the click event.

Create a view of how your results should be displayed, we'll name it myView.

Create a form called $$Search Template for myView. Add a field called $$ViewBody (text, editable, no value). Your results will populate using myView as a table within this field.

Ugly relevancy boxes will show up in the first column. To hide these, include the following pass-thru HTML script prior to $$ViewBody. (This will hide all images in the table, so icons won't appear either.)

<style>TABLE IMG{display:hidden}</style>

To display the number of results, add a field named TotalHits (text,computed, value TotalHits, R5 only!). Then add text after:
Documents found.
Format it as you like. You should probably use computed text for the "s" in case only 1 doc is found. Formula: @If(TotalHits!="1";"s";"")

Add a pass-thru HTML link to search again on the bottom of the form just to complete it:

<a href="/databasePath/mySearchForm?OpenForm">Search Again</a>
or... Add a button w/ this formula:

Questions? Check out the ancient SrchSite.ntf db design. It comes with Domino. Happy Searching!

Dig Deeper on Lotus Notes Domino Administration Tools

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...