1

When I try search a record my on my site using "Search this Site" search bar it seems to not work. Do I have to set it up first or what does the search bar even search?

Thank you. enter image description here

enter image description here

3 Answers 3

0

OK, here's a much better way to implement the search box solution, with very little coding needed. The steps are in SharePoint 2010, because that's what I have, but hopefully they are similar in 2013.

  1. In the view where you want to add the search box, go to Site Actions -> Edit Page
  2. Click on Add a Web Part. Select Category: Forms and Web Parts: HTML Form Web Part. Click Add.
  3. (Optional but recommended) In your new HTML Form Web Part, pull down the web part menu and select Edit Web Part. Under Form Content Editor, click on Source Editor.... A text editor pops up with the following code:

    <div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_"><input type="text" name="T1"/><input type="button" value="Go" onclick="javascript:_SFSUBMIT_"/></div>
    

    If you wish, change value="Go" to be more descriptive, for example:

    <div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_"><input type="text" name="T1"/><input type="button" value="Find Legacy AFE" onclick="javascript:_SFSUBMIT_"/></div>
    

and press Save.

  1. In the HTML Form Web Part, pull down the web part menu and select Connections -> Provide Form Values To -> WIP Tracking_22415 (I believe that's your listname, and it's probably the only choice you have anyway).

  2. You get a popup box for "Choose Connection". For Connection Type, choose Get Filter Values From and click Configure. For Provider Field Name, leave it as T1, for the Consumer Field Name, select Legacy AFE.

  3. Click on Stop Editing.

The above should work so that if you enter a search term and click the button, the view will now show any record that has an exact match in the Legacy AFE column.

11
  • Hi I tried this but it seems that the page refreshes but dosnt find anything ? Commented Mar 2, 2015 at 13:44
  • As we established in our private chat, your values all have 2 spaces in them, so I suggest that you replace the Source Code with the following: <div onkeydown="javascript:if (event.keyCode == 13) { $('#T1').val($('#T1').val().replace(/\s+/g,' ')); _SFSUBMIT_}"><input type="text" id="T1" name="T1"/><input type="button" value="Find Legacy AFE" onclick="javascript:{ $('#T1').val($('#T1').val().replace(/\s+/g,' ')); _SFSUBMIT_}"/></div> Note that the second argument of the replace function has 2 spaces in it. This will change any number of spaces in the search string to 2 spaces. Commented Mar 2, 2015 at 18:16
  • so my view, I need to have a script editor part with the code above, and also a HTML FORM web part? Commented Mar 2, 2015 at 19:26
  • No, use the above as the code in the html form web part. Commented Mar 2, 2015 at 19:51
  • When I open the Source editor, and replace the code with the one above it cancels out saying, " Cannot retrieve properties at this time" and also cannot save your changes Commented Mar 2, 2015 at 20:23
0

Check your Library Settings -> Advanced Settings, and make sure that Search: "Allow items from this document library to appear in search results" is set to Yes.

9
  • "Yes" was already chosen for Allow items from this list to appear in search results? but it still didn't work. Commented Feb 26, 2015 at 21:28
  • How long ago was the record added? It may not have had time to be indexed? Commented Feb 26, 2015 at 22:09
  • The answers to this question might be useful: sharepoint.stackexchange.com/questions/27731/… Commented Feb 26, 2015 at 22:23
  • I haven't found a definitive source for this, but based on experimentation, it looks like text fields (single line or multi-line) don't get crawled unless they've been defined at the server level as managed metadata (which Title and Name fields are by default). However, I've found that Lookup fields do seem to get crawled and indexed, so if the field you are interested in is amenable to being turned into a Lookup field, that might be a solution. I hope someone more knowledgeable than I will confirm or refute. Commented Feb 26, 2015 at 22:56
  • it has been more then 24 hours. Commented Feb 27, 2015 at 4:28
0

Another possible solution for you, if you want your users to be able to look up records by that column specifically, would be to add a form for filtering the records shown. You could add something like this in a content editor web part (html source or preferably as a file in the Content Link):

 <table summary="Legacy AFE Filter"><tr>
 <td><input id="LegacyAFEFilter" type="text"></td>
 <td><input class="highlightInputBasic" onclick="javascript:searchByLegacyAFE()" type="button" value="Find Legacy AFE"/></td>
 </tr></table>
 <script language="javascript" type="text/javascript" src="wherever-you-have-your-jquery-library/jquery.min.js"></script>
 <script language="javascript">
 function searchByLegacyAFE() {
    var legafe = $("#LegacyAFEFilter").val();
    var currentURL=window.location.href.split('?')[0];
    var filteredURL=currentURL+"?FilterField1=Legacy%5Fx0020%5FAFE&FilterValue1="+encodeURIComponent(legafe);

    window.location.href=filteredURL;
 }
 </script>

I took a guess at what your field name might be -- you might need to change the FilterField1 value. And this assumes you have jQuery somewhere (if not, it's free and will make your life easier, get it). You can of course get fancier with your script -- I stripped off any existing parameters from the URL for simplicity.

11
  • Hi I added the jquery.js file to site assets, then added this script in script editor. I see the input box, but when I enter the legacy afe and click "Find legacy AFE" it dosnt do anything Commented Feb 27, 2015 at 15:39
  • <table summary="Legacy AFE Filter"><tr> <td><input id="LegacyAFEFilter" type="text"></td> <td><input class="highlightInputBasic" onclick="javascript:searchByLegacyAFE()" type="button" value="Find Legacy AFE"/></td> </tr></table> Commented Feb 27, 2015 at 15:40
  • ****code continued***** <script language="javascript" type="text/javascript" src="cloudsites.vzbi.com/sites/jppdatabase/SiteAssets/jquery-1.11.2.min.js"></script> <script language="javascript"> function searchByLegacyAFE() { var legafe = $("#LegacyAFEFilter").val(); var currentURL=window.location.href.split('?')[0]; var filteredURL=currentURL+"?FilterField1=Legacy%5Fx0020%5FAFE&FilterValue1="+encodeURIComponent(legafe); window.location.href=filteredURL; } </script> Commented Feb 27, 2015 at 15:40
  • Try adding alert("Test"); as the first statement after the { to see if the script is at least being called. If you get a popup saying Test, then add more alert statements between the other statements to see where it's going wrong. Commented Feb 27, 2015 at 16:06
  • I added the alert and the box came up when I clicked enter, but now im not sure were else to add it or how to debug it. Commented Feb 27, 2015 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.