How to create a form based search for the user Profile?

Solution

A lot of customers ask if it is possible to create a structured and advanced search for different fields of the user profile with User Profiles for Confluence.

The functionality to search for fields of the user profile is available out of the box after the installation of User Profiles for Confluence. You only have to type the name of the field and the search entry as shown in illustration 1 in the search input field of Confluence.

The disadvantage of this procedure is that the user has to know the designation of the field. A form is more comfortable for the users. With Adaptavist´s Advanced Search Plugin you are able to create a form.

How to use the Advanced Search Plugin to create a form to search

  1. Think about which fields do you want to include in the form
  2. Navigate to the administration and look for the designation of the user profile fields in the menu entry "User Profile Plugin".
  3. Create a Wiki page for inserting the advanced user search with the Adaptavist´s Advanced Search Plugin.

The following little example describes how you have to use the Advanced Search Plugin to create a form based search for the user profile.

Imagine that the profile has the fields "team", "department", "skills", "city" and "phone". If you want a form for searching these fields copy the following code and paste it on a Wiki page for the advanced user search.

h2.User search
{search-form}
| Team: | {search-input:type=text|match=metadata|metadataKey=Team} |
|Department: | {search-input:type=text|match=metadata|metadataKey=Department} |
|Skills: | {search-input:type=text|match=metadata|metadataKey=Skills} |
|City: | {search-input:type=text|match=metadata|metadataKey=City} |
|Phone: | {search-input:type=text|match=metadata|metadataKey=Phone} |
{search-submit:submit search}
{search-form}
{search-results}

The macro {search-form} defines the search form. You have to assign the value "metadata" to the parameter "match" and the name of the field to the parameter "metadataKey" in the macro {search-input}. The value of the parameter metadataKey defines which field of the user profile you´re looking for.

Before closing the form with {search-form} we define a button to start the search {search-submit:submit search}. The macro {search-results} is responsible to display the result of the search.

After saving this page the advanced user search is available for the users.