Spaces/Official ESi/Scriptaculous & Adv. Tags

Search over multiple fields

Bruce Ellis
posted this on July 20, 2009 15:09

As built-in to WebEOC, the search tag can be used on only one field (per display view), but with a little work around, it can be used to search multiple fields.

 
The workaround will take several fields, concatenate them, and place them into a hidden field. By the way, many of these techniques I found in the forums at www.webeoc.com.
 
Here's the steps:
 
1.  Add a hidden field on the input view.  In this example, the field is a textarea called SearchText:
 
   <textarea name="SearchText" rows="4" cols="60" style="display:none;"></textarea>
 
 
 
2. Add the following javascript in the input view html. The field names in the runWhenSubmitted function will need to be modified for your particular fields. In this example, the board is a contact information directory. All of the fields (first name, last name, phone numbers, etc.) are put into one string variable called strText.  strText is then placed into the SearchText field. The script(s) will run automatically when the user clicks the Save button (in other words, when the "form is submitted").
 
<script type="text/javascript">
 
function runWhenSubmitted() 
{     
 
var strText = document.forms[0].LastName.value + " ";
 
strText += document.forms[0].FirstName.value + " ";
strText += document.forms[0].Title.value + " ";
strText += document.forms[0].Entity.value + " ";
strText += document.forms[0].Department.value + " ";
strText += document.forms[0].Division.value + " ";
strText += document.forms[0].OfficePhonePrimary.value + " ";
strText += document.forms[0].OfficePhoneSecondary.value + " ";
strText += document.forms[0].CellPhone.value + " ";
strText += document.forms[0].Pager.value + " ";
strText += document.forms[0].Fax.value + " ";
strText += document.forms[0].Notes.value + " ";
 
document.forms[0].SearchText.value=strText;

}
function SetSubmitHandler()
{    
  document.forms[0].onsubmit = runWhenSubmitted;
}
window.onload = SetSubmitHandler;
</script>
 
 
 
3. On a display view, use the search tag with the SearchText field. This field does not have to be included in the display board.
 
   <search field="SearchText" exact="false"></search>
 
 
 
4. Enjoy the priceless joy of a workaround that works.
 

Comments

User photo
Charlie Blanch
Ministry of Health

We've recently deployed just that solution to our Position and Sig Event boards and our Tasking boards and it works great searching on user, session name, subject, description, etc etc

The big issue is that the TaskID with over 7000 position log entries is now used as the default reference to tasks and position log entries i.e. ref Task 4356, but my understanding is that the Task ID is not created until the record is saved and therefore does not 'exist' for the purpose of being a field that can be copied across to the hidden search field by the java script when the record is submitted.

One fix may be to allow multiple search fields - so you can search the strtext and also the task ID But at the moment it appears to be one or the other.

Any other approach or does this need to be submitted as an enhancement request?

July 21, 2009 21:28
User photo
Gerrit Oertel
ESi

There is also some more valuable information about this search functionality here:

http://support.esi911.com/entries/33559-search

August 24, 2010 10:15