In last few years I 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 his at “3 letter acronym” technology (ASP, PHP…)

Phonebooks are being used when an employee needs to call a coworker on office number or when a receptions wants to inform you that someone is waiting for you in the lobby. In large organizations you must have such an application.

people-search2

Windows SharePoint Services already has Contacts list feature built-in, it only misses one thing: some form of quick search of contacts. So I made search-as-you type functionality for WSS Contacts list.

It is similar to Search as you type by Jan by 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

var sharePointSite = “http://<sharepoint_site_url_with_contacts_list>”; //e.g. “http://intranet”

var contactsListName = “Contacts”; // enter your Contacts list name here

  • (Optionally) Update Jquery location if you would like to use it from another location

Credits

I was partially inspired by Search as you type by Jan Tielens, I used Javascript API for the SharePoint webservices by  Darren Johnstone to query the data and  jQuery PHP Ajax Autosuggest by Ashley to create suggestion drowpdown.

Hope you will find a good use for this one…

18 Comments

  1. RF Says

    Hi – that’s great – thank you. One question – does it have to be a specifically a “contacts list” to work? We have a custom list that we modfied to hold our contact information that is imported form active directory.

  2. Thangeswari Says

    Thank you very much for sharing the useful script.Really cool.

  3. Toni Frankola Says

    @RF: You would have to make some minor modifications to the CAML query and the results part of the code and use it with any other custom or OOTB SharePoint list. Let me know if you need some help with it…

  4. Jason Says

    @Toni: turns out it does work on https, I didn’t realize the list has to be named Contacts even though there is a variable at the top of the script to define the name of the List.

  5. Toni Frankola Says

    Oh, great!!!

  6. Craig Says

    I’m trying to use this for our intranet and keep getting an access denied JS error … any ideas?

    This would really help in a couple places, so I’d like to get it working.

    Thanks,

  7. Toni Frankola Says

    @Craig: Can you post the actual JS error?

  8. vêtements enfants Says

    Pretty good this site

  9. Dan Says

    I to would like to use this w/ a custom list that we created for contact information (with lots of custom fields)…
    Toni you had asked post #1 if he needed any help to let you know, also he didn’t post back if he had any success..either way, If you could just possibly give some more elaboration as to what and where in the file to modify…as i’m not sure what caml is exactly, it would greatly be appreciated!

  10. Toni Frankola Says

    @Dan email me via contact form.

  11. mersin web tasarım Says

    Hello, very very good web site. Thank you.

  12. mersin tüp bebek merkezi Says

    Hello, beautiful site. Thank you.

  13. Jure Says

    Hi!

    Script doesn’t work in localized version (I’m using Slovenian and I’m getting Internal Server Error). If site has English for default language, than it works normally.

    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!

  14. Toni Frankola Says

    @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.

  15. Janko Says

    hello,

    I`ve made some modifications using the CAML tool posted before.

    var sharePointSite = “http://portal.domain.com”; //e.g. “http://intranet”
    var contactsListName = “Contacts”; // enter your Contacts list name here

    $(document).ready(function() {
    $(“#Search”).keyup(function(e) {
    var query = $(this).val();

    var lists = new SPAPI_Lists(sharePointSite )
    var items = lists.getListItems(
    contactsListName, // listName
    ”, // viewName
    ‘+query+’, // query
    ”, // viewFields
    30, // rowLimit
    ‘TRUE’ // queryOptions

    However I get no errors and also no results??

  16. Janko Says

    some rows were not posted …

    again ….

    // viewName
    ‘+query+’, // query
    ”, // viewFields
    30, // rowLimit
    ‘TRUE’ // queryOptions

  17. Kim G Says

    AWESOME! Do you know how to get the message for mixed content to stop happening without having everyone make the the fix in IE8? “do you want to view only the webpage content that was delivered securely” … is it something to do with a reference in the code?

  18. Jim Says

    Hi,

    I found your script very useful and I tried to use it on our sharepoint 2010 but it doesn’t work. I changed the lines accordingly and paste the script in content editor webpart but when I tape name to search it shows nothing, and when I hit enter I hear only a sound but nothing happens then. Please can you help me? And how do I need to customise my list to fit the CAML query in your script?
    Many Thanks,

    Jim

Leave a Reply