Use Query String (URL) Filter to filter the List and the Search Results

I wanted to list on a page an entity and all the associated contacts for that entity that had user logins. The entities themselves were all entered into a SP list and user profiles had their related entity setup in their department field.

On a new page I added three web-parts:

  • Query String URL Filter
  • Entity List
  • Search Results

Edit the Query String URL Filter web-part so that:

  • Filter Name = QueryString (or anything you want)
  • Query String Parameter Name = MyParameter1 (or anything you want)
  • Default Value = the name of the entity you want to show by default, if no default then leave blank

Setup up a Connection on the Entity List web part so that the list ‘gets filter values from > Query String (URL) filter’, in particular the MyParameter1 should be used to filter the Entity Title (or whichever field defines the entity).

Setup the Search results web part as follows:

  • Change Query:
    • Select a query = Local People Results (System)
    • Query Text:
{searchboxquery} contentclass=spspeople Department={QueryString.MyParameter1} 
(you can use the Property Filter to fill the Query text or just copy it in - yu can test the code using the TEST tab, e.g. contentclass=spspeople Department=ENTITY1 ContentClass=urn:content-class:SPSPeople)
  • Show Result Count = tick
  • Show sort dropdown = tick
  • Available sort orders (JSON):
 [{"name":"First name (A-Z)","sorts":[{"p":"FirstName","d":0}]},{"name":"First name (Z-A)","sorts":[{"p":"FirstName","d":1}]},{"name":"Last name (A-Z)","sorts":[{"p":"LastName","d":0}]},{"name":"Last name (Z-A)","sorts":[{"p":"LastName","d":1}]},{"name":"Social distance","sorts":[]}]

If you wish to change the web-part to show a list then download and implement the web-part layouts from http://www.sharepointconfig.com/2013/05/how-to-create-a-simple-sharepoint-2013-people-directory/ (http://www.sharepointconfig.com/downloadPeopleDirectoryDisplayTemplates.zip). Once downloaded follow the instruction to upload the two files into Site Settings > Master Pages and Page Layouts > Display Templates > Search, set the Search Results Display Templates to to use the *People Table Item.

 

*Note: to ensure the table layout works for everyone go to Home Site Settings > under Site Collection Administration select Manage Result Types > in the first sentence on the page click on “display template” > ensure the Approval Status of all required instances is set to “Approved”

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s