Awesome fast, easy and efficient searches on a Notes database over the web using javascript. A client had requested that we create search functionality for our Corporate directory. The key was that they wanted a custom look on the page and that the search be applied to only certain fields in this database and that the results be displayed in alphabetical order without the relevence boxes?. Outch! We tried to build the search in Lotusscript? it seemed to work great at first, but as soon as we added any type of user load it would take a long time to return the results (3-4 minutes), it's a huge database. We then tried the following method which has worked like a charm! Enjoy!
"Elements involved:
Search form where the entry field is contained: SideBar
The search results form: $$SearchTemplate for WebSearch
View that will contain the search results: (WebSearch)
I added this script around the $$ViewBody in the $$SearchTemplate for WebSearch:
<script>
sortit=new Array();
j=0;
$$ViewBody
sortit.sort();
document.writeln("<Table>");
for (i = 0; i < sortit.length ; i++)
{
ss = sortit[i].toString();
pos = ss.indexOf("[");
disp = ss.substr(pos+1);
document.write(disp);
}
document.write("</Table>");
</script>
I have a field called ?namesearch? where the user will enter a name to search on:
?namesearch? (editable text field)
In the form where the user is entering the name to search on, the following code must be added to the $$Return This code builds the url to be used in the search that will bring back the specific info we need from designated fields only.
criteria := @If(@Contains(namesearch;" ");@ReplaceSubstring(namesearch;"
";"+OR+");namesearch);
"<script>history.back();
parent.Body.window.location="/Corporate+Directory/Corporate.nsf/WebSearch/?S
earchView&Query="+"[LastName]"+"+CONTAINS+"+
"("+criteria+")"+"+OR+"+"[FirstName]"+"+CONTAINS+"+
"("+criteria+")"+"+OR+"+"[givenName]"+"+CONTAINS+"+
"("+criteria+")"+"+OR+"+"[Seat]"+"+CONTAINS+"+
"("+criteria+")"+"+OR+"+"[NABUserID]"+"+CONTAINS+"+
"("+criteria+")"+"";self.location.reload()</script>
In the view ?(WebSearch)? I added the following code to the first column that displays the information to the web client? all the HTML formatting is used to display the information returned in a pleasing manner:
"sortit[j]="" + LastName + "," + FirstName + "[" +
@Trim("
This was first published in November 2000