Tip

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!
CREATING THE SEARCH FORM:
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);

@If(string!="";"("+string+")";"")
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.

PART 2) THE RESULTS
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:
@URLOpen("/databasePath/mySearchForm?OpenForm")

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

This was first published in February 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.