PhoneBook Search – No code required
Contributing Author: Toni Frankola, SharePoint Use Cases
Over the last few years I’ve worked with many clients in different industries. Every company I worked with had one application in common: a centralized phonebook. These apps are usually written by some IT rookie that had a desire to show how good he is at "3 letter acronym" technology (ASP, PHP…)
Phonebooks are being used when an employee needs to call a coworker on an office number or when a receptionist wants to inform you that someone is waiting in the lobby. In large organizations you must have such an application.

Windows SharePoint Services already has a Contacts list feature built-in, but it only misses one thing: some form of quick search of contacts. So I made a search-as-you type functionality for WSS Contacts lists.
It is similar to SharePoint Search-As-You-Type with JQuery by Jan Tielens but it does not require MOSS and it searches only one list. So if your search is not working or not indexing your contacts, this web part will still work.
Deploying
- Upload this web part or paste this script to Content Editor Web Part
- Modify the following two lines with your SharePoint URLs and Contacts list name
var sharePointSite = "http://"; //e.g. "http://intranet"
var contactsListName = "Contacts"; // enter your Contacts list name here
- (Optionally) Update the Jquery location if you would like to use it from another place
Credits
I was partially inspired by SharePoint Search-As-You-Type with JQuery by Jan Tielens. I also used Javascript API for the SharePoint webservices by Darren Johnstone to query the data and jQuery PHP Ajax Autosuggest by Ashley to create the suggestion drowpdown.
Hope you will find a good use for this one…
Author: Toni Frankola SharePoint Use Cases Toni started his Web adventure in late 90’s and has been working with various web technologies ever since.
Toni is leading project engagements and managing a team of consultants specializing in Microsoft technologies. His primary focus is on Microsoft Office SharePoint and Dynamics CRM. He works at Perpetuum Mobile, a Microsoft Gold Partner from Croatia.
Thanks Toni:
Will this work on any List, not just Contacts?
You can actually use it to query from the user profile too. (using the user profile WS)
The link for the code is not working…
Dave – Yep, it is. Just checked. When you get to the download page, use your right mouse button and choose “Save target as…”. That will save it as an HTML page, view the source, and you get the code. — Mark
Nice work – Could this be adapted to also display an image from the list e.g. contact picture ?
Toni,
I am a newbie to Sharepoint. What do you mean when you say:
var contactsListName = “Contacts”; // enter your Contacts list name here
Does that mean I have to create a contacts list within Sharepoint or can I use the url call with the user profile web service? Since the contacts list will always have employees coming and going, I was hoping to use a dynamic list.
Sorry if the question is simplistic…
Very nice, thanks for looking out for us guys that dont have MOSS. I do have a question. When I first applied this to my list it did not work. Then I realized my list was modified from the default Contacts. Once I Created the default contacts it worked perfectly. If the Query is modified in the script, can this be applied to another list, maybe not contacts or a modified version of contacts?
Looks like you can not use this https. I have tried it on our dev environment which it works great, but with https if tosses out an error.
This did not work for me. Not sure why, but I created a generic Contact list and added a few names to test. Web part is on the same page as the Contacts list.
@Ben: No this is query for a simple list. User profiles are cool but the problem is these are extracted from AD data. Usually only the HR department has the correct information about an employee (phone, email, cell) and HR dept employees do not know how to modify data in AD. It is much more simpler for them to use a simple SharePoint list. There is solution from http://www.bambosolutions.com/ that syncs User profiles with a Contacts list.
@larry: sure the query is right in. There might also be problems with non-english SharePoint editions…
@all: Jason managed to solve the problem, and the solutions does work with HTTPS.
@Herb: This solutions uses JQuery from outside location. Check with your IT depertment maybe they are blocking it. The alternative is to place JQuery library locally on your SharePoint.
Depending on your security settings Javascript could be disabled completely on your browser.
I have successfully uploaded this web part, but when I type a contact name to search, I am getting an internal server error. Plz do needful.
Hello Toni
How do you solve the problem of HTTPS as im attempting to use this on WSS and having no luck.
I also got the “Internal Server Error” message.
Hello Toni,
I tried your webpart on our intranet and it’s working really good.
I would like to use it on our internet site, is it possible to search in a pages library instead of contact list?
Hi ,
I Paste the Script in Content Editor Web Part but i am getting below error. Can u please give me the solution.
Default Use for formatted text, tables, and images. true MiddleColumn 0 Normal true true true true true true true Modeless
Default
Cannot import this Web Part. /_layouts/images/mscontl.gif Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c Microsoft.SharePoint.WebPartPages.ContentEditorWebPart
Search as you type:
I have a list already created which is grouped by department and when i create the webpart with the url path to the list nothing happens i get no returned results. please help….
@Jarret: Save your list as template end email it to me to check what’s wrong. > [email protected] (replace it with my name)
Hi!
I’ve found this script, but when I type, I also get Internal Server Error. I modified first two variables and copied jquery-latest on sharepoint server and corrected path in first line.
I tried on existing and new contats list.
Could you please help me to find what am I doing wrong?
Is it possible that error is due to localized version of Sharepoint (WSS 3.0, W2k8 x64, Slovenian localization)?
Hi again!
I can confirm, that script doesn’t work due to localizaton. I created new test site collection with english language, created new contact list and pasted code. It works normally (no more Internal Server Error).
Now, becouse I have no programming skills at all, my question is: what should I change in scripts (probably var names for FirstName etc?)?
Thanks!
@Jure: Yes, ever localization has different internal field names and you need to change the CAML query to match names in your localization. This tool is very helpful for discovering internal field names: http://www.u2u.be/Res/Tools/CamlQueryBuilder.aspx. Give it a try! In case you cannot resolve it ping and I will see what I can do.
I tried as you said. If i’m correct, querry is made in lines 15-19, probably you think those filed names? They are same as in english version. Am I looking wrong part of code? With QueryBuilder there is a difference. Let say field “First Name” is in slovenian “Ime”. But searching through code, and I couldn’t find “First Name” string.
I would appreciate any further help.
Thanks in advance!
Hi Toni
Great work !
Can you tell me if I can use this solution to search LOOKUP fields. I have made a test (modifying some fields in your code to point to a list I have with lookup fields) and it returns an “internal Server Error” + an event id error 2436
I have changed the code as follow (my fieldname & value Type LOOKUP
…’ + query …
Everything is fine if I search only TEXT fields
Any idea?
thanks
philippe
This is great! thanks heaps, one issue I have however is that the suggestions dropdown box is slightly transparent. So whilst it sits above the Contacts list, the toolbar text (new, actions, settings) shows through making the results hard to read.
It would also be nice if the results could be cleared by clicking in “whitespace” not having to delete the entries in the search field too.
Very useful for those of us without MOSS! How difficult would it be to add additional fields to the search? I would like to include the job title, department, and maybe even the city name.
I got the fields added and it works great! But it appears to sort the results by ID…where in the script can I change this? I want to sort by last name (title), first name.