| You want to set up a customised search form to allow users to search the database by field. For example, in an industry news database, you want to search by company and/or by country
 and/or by any word or phrase.
 
 
 Solution 1:
 
 1. Build a search form. Include the keyword fields
 “Company” and “Country”. The keyword fields perform
 an @DbColumn into hidden views to obtain the lists of
 companys and countries. The search form can be
 called whatever you want but it must have the
 alias “$$Search”.
 
 2. Also include an editable field called “SearchKeywords”
 so the user can search for specific words and phrases.
 
 3. The keyword fields list of values must begin with a
 blank value or a prompt value such as
 “Select a company”. This is achieved in your list
 value formula by using: “Select a company” :
 @DbColumn(.... etc
 
 4. Build a field called “Query” that converts the user
 keyword selections into a valid full text query e.g.
 “FIELD Company contains Acme”. A suitable formula
 would look like this:
 
 tSearchKeywords := @If(SearchKeywords != “”; @Implode(SearchKeywords; “ AND “);
 “”);
 tCompany := @If(Company != “Select a company”; “Field Company contains “ +
 @Implode(Company; “,”); “”);
 tCountry := @If(Country != “Select a country”; “Field Country contains “ +
 @Implode(Country; “,”); “”);
 tAll := “(“ + @Trim(tSearchKeywords : tCompany : tCountry) + “)”;
 @Implode(tAll; “ AND “)
 
 
 5. Add a button to the form with the title:
 “Start the search”. The button does not have to have
 a formula behind it.
 
 
 6. Add a hidden computed for display field called
 “$$Return” with the following formula:
 
 “[[/your_db.nsf/your_specific_search_view/?SearchView&Query=” + Query + “]]”
 
 The second part of the URL formula refers to the view that will be searched. It is best to use a
 view that contains all documents. Solution 2 on this site describes how to search the user’s
 current view rather than a specific view.
 
 
 7. Add a search action button or hotspot on all views to execute the search URL which looks
 something like this:
 
 @URLOpen(“http://your_server/your_db.nsf/your_search_form?OpenForm”)
 
 Note that it is possible to build other fields in the search form to allow users to select full text
 options: use thesaurus, include word variants, etc.
 
 
 
 Solution 2:
 
 Search by form in the user’s current view instead of a specific view. You have already set up a
 database search by form. The search button on your view executes the search URL which looks
 something like this:
 
 @URLOpen("http://your_server/your_db.nsf/your_search_form?OpenForm”)
 
 The search form contains a $$Return field which executes a URL as follows:
 
 “[[your_db_name/specific_search_view_name/?SearchView&Query=” + Query + “]]”
 
 where the computed Query field contains the search string and search options.
 
 
 previous page
 
 
 |