For one of our Office 365 customers, I had to extend the SharePoint Advanced Search Web Part with additional properties:
The customer has metadata applied within their Office 365 portals such as company, project name and project status. How can we add the metadata to the property menu within the web part? Just follow my lead!
You have to be a global administrator within your Office 365 tenant, otherwise you can’t configure all the necessary components. Our first stop is the Managed Property menu. Go to your SharePoint Online admin center and click Managed Search Schema
. The following screen appears:
Hopefully you are aware of the fact that SharePoint Online has limited options for new managed properties (more about this later) and that’s why Microsoft created a bunch of predefined managed properties. These are called RefinableDate, RefinableDecimal, RefinableDouble, RefinableInt and RefinableString. You can re-use these managed properties and connect them to your custom metadata. This is very useful for search results refiners, I wrote an article about this almost a year ago.
The reason you use the predefined managed properties is immediately clear after you click New Managed Property:
You can’t use a new managed property as a refiner. The out-of-the-box Refinable managed properties are able to refine:
Great! So here is where I made a big mistake. I used the predefined managed properties within the advanced search property menu. Guess what happened? Nothing, that’s what happened. The custom metadata didn’t appear in the advanced search property drop-down menu. Why not? This is why:
The Refinable managed properties aren’t searchable! The option is greyed out. This means you have to create a new managed property if you want to use the custom metadata within the advanced search. The following screen shows that new managed property is searchable:
Let’s just ignore the fact that this is very annoying and you are stuck with basically double managed properties for the same custom metadata. Did you create your new managed property? Checked the Searchable checkbox? Attached your crawled property? Alright, ready to move on to our second and final step! Edit the Advanced Search Web Part:
Click within the Properties bar and three little black dots appear on the right side. Click these to open the Text Editor:
Let’s ignore the fact that this is the most user unfriendly text builder in the world, so I normally copy the content to Notepad. Quick tip: Save the original code somewhere safe, in case you mess up. You have to add the custom metadata in the following sections:
<PropertyDef Name="YourManagedProperty" DataType="text" DisplayName="Name displayed in the drop down"/>
<PropertyRef Name="YourManagedProperty" />
Save the code back into the text builder. Click OK
and then save the web part and publish the page. Let’s take a look at the drop-down menu with the custom metadata changes we just made:
The custom metadata is now available. I hope you found this article useful and don't have to struggle as much as I did.