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.

Sunday, January 22, 2023

Using the PnP Modern Search Results web part as a Department Web Part



Update: If you prefer the video version you can find it here: Using PnP Modern Search As Department Web Part - YouTube
Occasionally we get the request to display the members of a department on a modern SharePoint web page. Using the People Web part is out of the question as this web part only shows a static list of people, and we want the listing to show the members of the Department at any given time.
The Organization Chart is an option if your departments always have one manager, and each manager only has one department. 




However you might be looking for something a little more flexible than the Org Chart, and the PnP Modern Search solution can provide just that 😀

Before you can start using PnP Modern Search the solution must be installed in the App Catalog as per the official guide to PnP Modern Search

Even before we start working with the web part we need some information, the ID number for the department in question.
You find the list of departments in the Term Store. Find the department in the People group and select the Usage Settings in the right hand section, and there you will find the unique ID for that department. 



Back on the modern page again.

Once the App is installed in your site the steps are as follows:
1) Edit the page
2) Insert the Web Part (PnP Search Results)



3) Select Configure or click the Edit Web part Icon
4) Select SharePoint as the Data Source
5) Enter owstaxIdSPShDepartment:"THE_ID_OF_THE_DEPARTMENT" in the Query Template Field, in this case it will be owstaxIdSPShDepartment:"2ce09d31-c9d3-4265-abd7-5ac99fc3a060"
6) Scroll down and select LocalPeopleResults in the Result Source Id/Scop|Name field




7) Now you should see some results in the web part, however we are currently using a wrong layout/Display. Scroll further down and change to Page 2.
8) Select the People Layout 
9) Scroll down and enable the field "Show persona card on hover"
10) Change the Component size to a value that fits your design.



11) Rename the web part to the title of the department.

And here you go, an always updated department web part free of change.