SharePoint Use Cases

20 Aug, 2009

Use case: PhoneBook Search – no code required

Posted by: Toni Frankola In: SharePoint

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…



Documentation Toolkit for SharePoint

Comments

1 | RF

August 21st, 2009 at 8:57 am

Avatar

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

August 21st, 2009 at 12:53 pm

Avatar

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

3 | Toni Frankola

August 24th, 2009 at 10:04 am

Avatar

@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

August 26th, 2009 at 12:08 am

Avatar

@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

August 26th, 2009 at 12:29 am

Avatar

Oh, great!!!

6 | Craig

August 31st, 2009 at 1:17 pm

Avatar

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

September 14th, 2009 at 12:02 pm

Avatar

@Craig: Can you post the actual JS error?

8 | vêtements enfants

September 28th, 2009 at 12:57 am

Avatar

Pretty good this site

9 | Dan

November 2nd, 2009 at 2:26 pm

Avatar

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

November 3rd, 2009 at 9:30 am

Avatar

@Dan email me via contact form.

11 | mersin web tasarım

December 18th, 2009 at 5:44 pm

Avatar

Hello, very very good web site. Thank you.

12 | mersin tüp bebek merkezi

December 22nd, 2009 at 1:10 pm

Avatar

Hello, beautiful site. Thank you.

13 | Jure

January 20th, 2010 at 3:51 am

Avatar

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

January 20th, 2010 at 4:19 am

Avatar

@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

January 26th, 2010 at 1:11 am

Avatar

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

January 26th, 2010 at 1:14 am

Avatar

some rows were not posted …

again ….

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

17 | Kim G

February 12th, 2010 at 1:28 pm

Avatar

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?

Comment Form

 

About

Real-life use case and opinions about collaboration, CRM and web technologies and stuff by Toni Frankola. More...

Toni Frankola - SharePoint MVP Profile

All postings on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer.