Tuesday, January 24, 2023

Shortcomings of the Managed Metadata fields on a SharePoint User Profile

Summary: This blog post will explain what you can and can't do when the User Profile field is a Managed Metadata field.


This blog post is a fellow up on the previous post about using PnP Modern Web Parts as a department web part.

While working on that blog post I had the idea that it should be possible to show the members of a specific department and a division as well.





Showing the members of a department was easy, however I had a hard time getting the division to work.

According to an article from Mikael Svenson, I should be able to query for the Marketing Division by using the GPP|#c  syntaxwhich should return User Profile Accounts where the Department field was a term beneath the Marketing Division. 

Looking at the data using the excellent SP Editor extension for Chrome/Edge I found that the data looked just as expected where the Department termset was using on a Site Column. The search worked just fine.


So why didn't it work in People Search? 

After inspecting the Managed Property ( in this case ows_taxid_spshdepartment was mapped to RefinableString100) in SP Editor this showed up:







Once the Department field on the User Profile Account is crawled it does NOT contain the same value as if the field had been using on content.

So the short story is that we can use the PnP Modern Search solution to show departments and all employees, but not the levels between.

It is of course an option to set the query like ows_taxid_spshdepartment:[ID for Marketing] OR ows_taxid_spshdepartment:[ID for Sales] and so on. However, this option is brittle and will require an update each time a department is added or removed from the Division.