Setting Custom Sorting on Profile Table in SharePoint

Image Title

posted by Khoa Quach
on Jun 22, 2015

Most SharePoint intranet portals that I’ve built, implemented, and reviewed over the years always integrate a contact page that allows displaying employees’ information. Leveraging SharePoint search, search scope, and the new display template in SharePoint 2013, the task is a pretty simple one. I followed a great article with very detailed and straightforward steps posted
here. The following article is an extension to the functionalities built within a SharePoint 0ffice 365 environment.

A few weeks ago, one of my client asked if it would be possible to add extra sorting parameters to the default drop-downs. Initially, it was set to display information as follow:

  • First Name (A-Z)
  • First Name (Z-A)
  • Last Name (A-Z)
  • Last Name (Z-A)

The request was fairly simple: allow the ability to sort by the ‘Job Title’ property.

custom-sorting-1

>Well, I thought the request was fairly simple until I realize that things get handled a little differently on the O365 environment. In fact, in order for us to sort the ‘Job Title’ property, we need to ensure that the property is actually set to be sortable. Without this option checked, the SharePoint search will not allow sorting and will result in an error in the display view. My first thought was to log into the Office 365 Admin Panel and navigate to the SharePoint administration Panel.

Once there, you would click on Search Service and review the Search Schema. I looked for the ‘JobTitle’ metadata property and clicked on Edit to review the details.

 

Here is the kicker. You are not able to change the sort property of default SharePoint search metadata items on Office 365!

custom-sorting-7

OK, well I could create another one, map it to the same property and set the Sortable option to “Yes”. Once again, you can’t do that because Office 365 will not allow you to create a new managed property with an active sort.

The solution is to use one of the few created managed property fields that already exist for each possible field’s type. They all start by “Refinable” so they are pretty easy to find. You can choose multiple types:

  • text
  • integer
  • decimal
  • date
  • Yes/No
  • Double precision float
  • Binary

In my case, I used the RefinableString02 managed property.
I recommend creating an alias so that you can target (always better than the random name). I edited the property, set the same mapping than the default “JobTitle” property, check that the sortable was set to “active” and give it an alias for example “JobTitleSortable”.

custom-sorting-6

That was the hardest part. Once you are done with this part, you only need to take care of 2 things:

  • Change the settings in the search results web part
  • Wait for an indexing of the SharePoint site

Unfortunately, this is not something that can be control on Office 365 (unless you just want to re-index lists or document libraries). So it’s a game of patience here. As defined by Microsoft, “In SharePoint Online, crawling happens automatically based on the defined crawl schedule”.

Sources:

Manage the search schema in SharePoint Online

How to: Create a Simple SharePoint 2013 People Directory