How to build a company directory app in 5 minutes (using Search and User Profiles)

A customer asked me about setting up a typical type of company profile application where you click on a letter and you can see the employees with that last name in a list. The speed at which I was able to fashion a completely functional application using just user profiles and search features caught me by surprise. I have seen these kinds of apps in SharePoint before, usually taking multiple components and hundreds of lines of code. This solution will take you about an hour. Ok, my title said 5 minutes but it is an exceedingly easy to build app.

Caveat, there are a few pre-requisites.

  1. You have to have a user profile service and some user profiles generated. The more complete the better of course.
  2. You have to have a search service running and configured.
  3. You have to be familiar enough with web parts and such to do this.

Step 1 – create a blank page on your site to host the 2 web parts you are going to need. You can use the wiki style page or a web part page
Step 2 – Add a Search Results web part to the page. Also add a content editor web part or just put the HTML onto the wiki page directly, creating a 13 column, 2 row table to hold the alphabet letters. Something like figure 1 below.

Step 3- edit the search results web part as follows:

  • Edit the web part. In the tool pane select the change query button
  • In the query builder window that pops up, fill it out as follows:
  • Select the query (local people results)
  • Remove the {SearchBoxQuery} filter from the Query text editor field
  • Add a property filter LastName:{QueryString:MyParameter1}   - note: the parameter name can be anything, it does not have to be “MyParameter1”, but whatever you use in this query you will need to use in the HTML later)
  • You can use the dropdown boxes to create this filter or just type it into the editor field directly. The results is shown in the image below
  • Click OK and stop editing the web part

Step 4- add HTML to the letters created in step 2. For each letter, add a link pack to the page with a query string parameter using the name defined in step 3 (MyParameter1 for this sample) and a value of the letter and a wildcard character…

Here is a sample for letters A and B. note Company%20Directory.aspx is the name of the page where we are adding these web parts
            <a href="/SitePages/Company%20Directory.aspx?MyParameter1=A%2a">A</a>
            <a href="/SitePages/Company%20Directory.aspx?MyParameter1=B%2a">B</a>

When a user clicks on a letter, it will reload the page, sending the parameters of the last name first letter and a wildcard. This will cause the search results web part to show all user profiles that begin with the letter in the query string.

That’s it. You may want to add a few visual embellishments for a full production app, but this is a fully functional directory if you have a decently filled out or synced user profile.

  |  

About Bluespring

Bluespring is a software development arm of Ascendum Solutions with a singular focus on helping organizations make work flow in Microsoft SharePoint.  We provide software and services that boost an organizations use of SharePoint to get critical information to the right people at the right time ... Read More

Stay Posted

Stay Posted

Sign up to receive the latest updates via email:

View Our Brochure

Download it Now