This site uses cookies and by using the site you are consenting to this. We utilize cookies to optimize our brand’s web presence and website experience. To learn more about cookies, click here to read our privacy statement.

Overcoming Office 365/SharePoint Online Development Challenges – Part 2

In Part 1 of this series I covered some of the challenges around implementing Business Connectivity Services challenges in Office 365.  In this part 2, I’ll cover some of the challenges I ran into when adding new managed properties to add refiners and sorting to the custom Search page.

I had a simple scenario of adding additional refiners to the People Search so I could sort the search results by First Name, Last Name and Job Title.   Since all these User Profile Properties are available in the Search, you would think that you should be able to sort the results as these managed properties are already mapped to the crawled properties.

So, I added the following code in the Search web part properties to sort by FirstName, LastName, and JobTitle.

Search webpart properties

[code language=”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":"Job Title (A-Z)","sorts":[{"p":"JobTitle","d":0}]},{"name":"Job Title (Z-A)","sorts":[{"p":"JobTitle","d":1}]}]

To my surprise sort only worked for First Name but not for Last Name and Job title.

Upon further examination of the managed properties by going to Manage Search Schema under SharePoint Online Admin Center in Office365, I noticed that sort was enabled only for the FirstName managed property and not for LastName and JobTitle as you can gather from the screen shots below.  Furthermore, these OOB managed properties are read-only so you really can’t change them to allow sorting.

Manage Search Schema



So you figure big deal, since you can just easily create a new managed property that points to the same crawled properties that OOB Last Name managed property is pointing to.   You are only partially correct.  As I found out Microsoft does not allow you to create a new managed property that is refinable or sortable as those options are grayed out.  So I scratched my head and decided to do some further reading on how to manage Search Schema in SP Online and came across this support article.

As described in this article, what Microsoft does is provide you with whole bunch of pre-created properties that you can modify.    For example, if you want to use the property as a refiner in the front-end, you must manually map the crawled property to a managed property that is set as refinable. To create a new refinable managed property in SharePoint Online , you must use an existing, unused managed property, and rename it by using an Alias. There’s quite a few managed properties available for this purpose. They have names such as “RefinableString00” and “RefinableDate19.

So I used two of these properties for LastName and JobTitle.  Phew!


I thought my job was done and I modified my code above to include the new RefinableString00 and RefinableString01 for Last Name and Job Title respectively.

{“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”:”Job Title (A-Z)”,”sorts”:[{“p”:”JobTitle”,”d”:0}]},{“name”:”Job Title (Z-A)”,”sorts”:[{“p”:”JobTitle”,”d”:1}]}]

But the sorting still did not work.  I scratched my head some more and did some additional reading on the web until I came across this excellent blog by Mikael Svenson.

I suggest you read his blog in detail, but I’ll summarize it here for you.   There are no full crawls executed on user profiles.   In order for your new managed properties to show up you need to update each user’s profile.    In addition User Profiles are incrementally crawled at an average of 4 hour intervals.    Luckily Mikael has a script that does the job for you.   His script is available at https://github.com/wobba/SPO-Trigger-Reindex.

Finally after waiting for about 4 hours for User Profile to get crawled my sorting started working.