locked
SharePoint List Search in Moss 2007 RRS feed

  • Question

  •  

    Hi,

     

     

    Is there anyway to search the specified sharepoint List in the current site in MOSS 2007?

     

    Thanks

    Vijay

    Wednesday, August 29, 2007 5:27 PM

Answers

  • Hey,

    I created a custom solution that works well for our company.

    I had a huge list, +8000 items. Our users needed a way to quickly find items to prevent entering duplicates.

    I also need to allow wildcard searching so they could enter partial text and return matching records.

    What I did was add a Content Editor Web Part to the list page, and entered in some Javascript code, a dropdownbox, a textbox, and two buttons. A search button and a clear button. into the sourcecode of the Content editor webpart.

    The dropdown list contains a hardcoded list of all the column names.

    the user selectes the column to search by picking it from the dropdown box, the user  then enters his search text in the textbox, and clicks the search button

    the javascript redirects the user to the same page with querystring data added to the URL.

    the clear button sets the querystring url back to blank, which in effect clears the search data, and the entire list is back in view.

    The sourcecode is as follows

    <script type="text/javascript">
     function RedirectUrl() {
     var tb = document.getElementById("tbSearch").value;
     var cs = document.getElementById("sfield").value;
     var url = "";
    
     if (tb != "") {
      if (cs == "Column5" || cs == "Column6"){
      url = "FilterField1=" + cs + "&FilterValue1=" + tb;
      window.location.href = "AllItems.aspx?" + url;
      }
      else {  
      url = "FilterName=" + cs + "&FilterMultiValue=*" + tb + "*";
      window.location.href = "AllItems.aspx?" + url;
      }
      }
      else {
      return false;
      }
     } 
     function ClearUrl() {
     window.location.href = "AllItems.aspx";
     }
    </script>
    Search Field: <select id="sfield">
    <option selected value="Title" >Person Name</option>
    <option value="Column2">Status</option>
    <option value="Column4">Case #</option>
    <option value="Column5">Date taken</option>
    <option value="Column6">DOB</option>
    <option value="Column8">other #</option>
    <option value="Column10">Notes</option>
    <option value="Column12">employee</option>
    </select>
    &nbsp;
    Search text: <input type="text" id="tbSearch" />
    <input type="button" id="btnSearch" value="Search" onclick="return RedirectUrl();" />
    <input type="button" id="btnClear" value="Clear" onclick="return ClearUrl();" />
    • Proposed as answer by DeoCarvalho Tuesday, October 5, 2010 4:54 PM
    • Marked as answer by Mike Walsh FIN Thursday, December 2, 2010 1:20 PM
    Thursday, May 6, 2010 4:02 PM
  • Yup, MOSS and WSS automatically create those scopes for you.  So open the list in question.  Then find your search box on the page.  Usually in MOSS you will see a drop down with All Sites Selected. You can click the drop down and there should be a choice for this list and this site.

     

    Shane - SharePoint Help

    Thursday, August 30, 2007 3:17 PM
    Moderator

All replies

  • Yup, MOSS and WSS automatically create those scopes for you.  So open the list in question.  Then find your search box on the page.  Usually in MOSS you will see a drop down with All Sites Selected. You can click the drop down and there should be a choice for this list and this site.

     

    Shane - SharePoint Help

    Thursday, August 30, 2007 3:17 PM
    Moderator
  •  

    Thanks for you response. In my dropdown list, i  couldn't find the this List option. I wold appreciate if give me the steps to Enable This List Option

     

    Thanks

    Vijay

    Thursday, August 30, 2007 10:54 PM
  • This is enabled by default / automatically, there is nothing you need to do to configure it. Are you sure you are on the default page for the list?

    The URL should look something like:
    http://yourapp/listpath/Forms/ViewName.aspx

    If you had a site URL of litware, and a list called widgets on the top level site, for the default view - All Items - it would be:
    http://litware/widgets/Forms/AllItems.aspx

    While on this page, you should see "This List" as an option in the Scope drop down. If you want to be able to search a particular list from other pages such as a customized page that has a web part that displays list items, you could create a new scope that's visible everywhere or in certain sites.
    Friday, August 31, 2007 3:48 PM
  • Hi,
    If you are looking for an effective tool to search over lists, consider this list search webpart: www.auraaddons.com
    It allows you to search based on specific columns, do free text search using wildcards and boolean operators.

    Thanks,
    Kunal
    Sunday, October 25, 2009 7:32 AM
  • Hey,

    I created a custom solution that works well for our company.

    I had a huge list, +8000 items. Our users needed a way to quickly find items to prevent entering duplicates.

    I also need to allow wildcard searching so they could enter partial text and return matching records.

    What I did was add a Content Editor Web Part to the list page, and entered in some Javascript code, a dropdownbox, a textbox, and two buttons. A search button and a clear button. into the sourcecode of the Content editor webpart.

    The dropdown list contains a hardcoded list of all the column names.

    the user selectes the column to search by picking it from the dropdown box, the user  then enters his search text in the textbox, and clicks the search button

    the javascript redirects the user to the same page with querystring data added to the URL.

    the clear button sets the querystring url back to blank, which in effect clears the search data, and the entire list is back in view.

    The sourcecode is as follows

    <script type="text/javascript">
     function RedirectUrl() {
     var tb = document.getElementById("tbSearch").value;
     var cs = document.getElementById("sfield").value;
     var url = "";
    
     if (tb != "") {
      if (cs == "Column5" || cs == "Column6"){
      url = "FilterField1=" + cs + "&FilterValue1=" + tb;
      window.location.href = "AllItems.aspx?" + url;
      }
      else {  
      url = "FilterName=" + cs + "&FilterMultiValue=*" + tb + "*";
      window.location.href = "AllItems.aspx?" + url;
      }
      }
      else {
      return false;
      }
     } 
     function ClearUrl() {
     window.location.href = "AllItems.aspx";
     }
    </script>
    Search Field: <select id="sfield">
    <option selected value="Title" >Person Name</option>
    <option value="Column2">Status</option>
    <option value="Column4">Case #</option>
    <option value="Column5">Date taken</option>
    <option value="Column6">DOB</option>
    <option value="Column8">other #</option>
    <option value="Column10">Notes</option>
    <option value="Column12">employee</option>
    </select>
    &nbsp;
    Search text: <input type="text" id="tbSearch" />
    <input type="button" id="btnSearch" value="Search" onclick="return RedirectUrl();" />
    <input type="button" id="btnClear" value="Clear" onclick="return ClearUrl();" />
    • Proposed as answer by DeoCarvalho Tuesday, October 5, 2010 4:54 PM
    • Marked as answer by Mike Walsh FIN Thursday, December 2, 2010 1:20 PM
    Thursday, May 6, 2010 4:02 PM
  • hi gavin,

    Your post is very useful to me but i am unable to filter the document library Name (linkfilename) and discussion board subject (linktitle) .please give me suggestion to me how to filter. 

    Friday, June 11, 2010 5:01 AM
  • dude i tried your solution but unable to filter the items, can please guide me through?

     

    Thanks in Advance!


    Share Knowledge and Spread Love!
    Monday, August 2, 2010 3:45 PM
  • Hello giri_chandu

    Instead of 'LinkFileName', use 'FileLeafRef' - this worked for me.

    Shark

    Thursday, August 12, 2010 8:30 AM
  • Beautiful, buddy! Worked like a charm to me.

    Once you get the names of the columns right there's nothing else you need to do. To figure out mine I went to the list settings and click to edit the column I wanted to know the name of. You can check how it looks like at the end of the url. Turns out if there's a space, you need to fill it up with %5Fx0020%5F.

    <!-- [if gte mso 10]> <mce:style>

    Thanks Gavin!

    Tuesday, October 5, 2010 5:01 PM
  • Gavin,

    I tried your javascript solution, however, when I do the search, no items are returned.  I have matched the columns exactly how they are within the list, below is what I am seeing in the Url:

     

    http://labsptweb1.ocsuperior.occourts.org:7777/ssp/admin/jrts/Lists/Web_Requests/AllItems.aspx?FilterField1=Column2&FilterValue1=Test

    Am I missing something, I used the same code you provided except fo a few changes, see below:

     

    <script type="text/javascript" >
      function RedirectUrl(){
       var tb = document.getElementById("txtSearch").value;
       var cs = document.getElementById("ddlColumns").value;
       var url = "";
       
       if (tb!=""){
        if (cs=="Column1" || cs=="Column2" || cs=="Column5"|| cs=="Column6"|| cs=="Column11"){
        url = "FilterField1=" + cs + "&FilterValue1=" + tb;
        window.location.href="AllItems.aspx?" + url;
        }
        else{
        url = "FilterName=" + cs + "&FilterMultiValue=*" + tb + "*";
        window.location.href="AllItems.aspx?" + url;
        }
        }
        else{
        return false;
        }
        }
        
        function ClearUrl(){
        window.location.href="AllItems.aspx";
        }
     </script>
     
     Search Field: <select id="ddlColumns">
      <option selected value="Title" > Select a Field to Search</option>
         <option value="Column1">ID</option>
         <option value="Column2">Subject</option>
         <option value="Column5">Department</option>
         <option value="Column6">Submitted Date</option>
         <option value="Column11">Status</option> 
     </select>
     
     Search text: <input type="text" id="txtSearch"/>
     <input type="button" id="btnSearch" value="Search" onclick="return RedirectUrl();"/>
     <input type="button" id="btnClear" value="Clear" onclick="return ClearUrl();"/>

    Any help would be appreciated.

    Thanks.


    bigRay
    Wednesday, October 13, 2010 4:49 PM
  • Hi Gavin,

    Such a wonderful post,

    Earlier i tried that code and facing the issue HTTP -404 Page not found error.

    What i was mistaking , I was adding the content editor webpart on HomePage of Subsite.

    Then after some time I release, That Content editor webpart , would be placed in List (i.e ListName/AllItem.aspx) Page.

    and Change the Column Name according to my List Column,

    Now Its workig absolutely fine.

    Thursday, December 2, 2010 12:42 PM
  • Ok it seems the code works well in the web part but when I search on a column and something I know is in that column the page refreshes and it shows all the data, it does not show just the rows with the data in it.  Here is the code as I modified it for my columns.

    <script type="text/javascript">
     function RedirectUrl() {
     var tb = document.getElementById("tbSearch").value;
     var cs = document.getElementById("sfield").value;
     var url = "";

     if (tb != "") {
      if (cs == "Column5" || cs == "Column6"){
      url = "FilterField1=" + cs + "&FilterValue1=" + tb;
      window.location.href = "AllItems.aspx?" + url;
      }
      else { 
      url = "FilterName=" + cs + "&FilterMultiValue=*" + tb + "*";
      window.location.href = "AllItems.aspx?" + url;
      }
      }
      else {
      return false;
      }
     }
     function ClearUrl() {
     window.location.href = "AllItems.aspx";
     }
    </script>
    Search Field: <select id="sfield">

    <option value="Column3">Author Name 1</option>
    <option value="Column4">Author Name 2</option>
    <option value="Column5">Author Name 3</option>
    <option value="Column6">Author Name 4</option>
    <option value="Column7">Title</option>
    <option value="Column8">Year</option>
    <option value="Column9">Publication/by</option>
    <option value="Column10">Publisher/For</option>
    <option value="Column11">City ID</option>
    </select>
    &nbsp;
    Search text: <input type="text" id="tbSearch" />
    <input type="button" id="btnSearch" value="Search" onclick="return RedirectUrl();" />
    <input type="button" id="btnClear" value="Clear" onclick="return ClearUrl();" />

    I expected a page to refresh and then only show the data in the list that matches the search query.

     

    Thanks

    Scott

     

     

    Wednesday, December 15, 2010 10:13 PM