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. 



 










Thursday, December 29, 2022

Deploy a custom Form Formatting as part of your Site Provisioning

 

Sometimes the default list "new Item"/Edit form is just not well suited as the number of fields causes the form to start scrolling and thus hiding some of the fields.




In the dark ages the default option was to use SharePoint Designer to modify the forms 😟, but today we have more choise based on your needs: 

  • Are you limited to only use out of the box SharePoint
  • Do you need to have logic in the form like if you entered option A in a field  then the options in the next field must be limited to a specific subset of options.
  • Should this list be provisioned to new Site Collections using a provisioning engine

If you need logic between the fields you will most likely choose to customize the list using PowerApps , however as far as I know is is not possible to deploy the PowerApp customization on multiple site collections.


If however you can do without the logic the most likely choice is to use Form Formatting  This will enable you to use the entire screen for your form and manage both the header, body and footer. The body can segregated into sections, making it easier for the end user to locate the fields:



        The PnP community maintains a repository of Form samples if you need some inspiration.



Once you have completed the Form customization it is time to extract it. The JSON configuration is a property on the Content Type, and the PnP sample provided by Kinga Kazala shows how to extract the JSON to a file.


Store the JSON file in SharePoint, setup an Azure Function as I have shown in the sample here, and you are done 👌

Wednesday, December 21, 2022

Yeah, SharePoint custom Search Display Templates are back*



Once upon a time (before SharePoint Modern mode, circa 2016) we were able to create  custom display templates for search results. This was a great option when your search query was returning a specific Content Type and you could display the various fields in a way that fit the content e.g. showing a red traffic light for expired content.

However when SharePoint Modern appeared on our tenants Microsoft decided not to provide any option to customize the out of the box search, a decision that is hard to understand.

Luckily for Microsoft and us the M365 Community rose to the challenge and the PnP Modern Web Parts project was born.

 

As of today, you can add additional MS Search Vertical on the Site and Tenant level, and we can only hope that one day we will be able to assign an Audience to a Vertical in order to ensure the relevancy for the end user. (hint hint)

 

And NOW (public preview late Dec 22 and complete mid Jan 23) we can create custom item display templates in the shape of Result types with associated Adaptive Cards:

 

 


 

Please note that the Rules is using KQL so all the old queries you have been using for years still works !!!

 


And the skill set required for beautiful looking Adaptive Cards is on my wish list for X-mas but at least I can cheat and learn from the masters at https://github.com/pnp/AdaptiveCards-Templates

 





(Hey it works
😊 )

Thursday, February 3, 2022

Don't pay more for SharePoint Storage than you have to :-)



This blog post will walk you through the potential challenges related the SharePoint Storage, and a few suggestions how to minimize your costs.


Even though most of us likes Microsoft, on some days more than others, there are no reason why we should pay more than necessary.

As you might know each tenant is born with a 1 TB SharePoint Storage allowance. On top of that you get 10 GB per licensed user.

Unless you already have a retention policy or similar in place that will delete the content of your SharePoint Site Collections as the time goes by, you will eventually run out of free SharePoint Storage. At the time of writing additional SharePoint Storage is available in the admin center at $0.20 per GB per month.

First of all it is important to know how the total SharePoint Storage is calculated. In the screen shot below you see the version history of a fairly typical file. It has been updated and reviewed a few times and currently we have a total of 25 versions.

It has been difficult to find any documentation from Microsoft confirming this, but as far as I know Microsoft calculate the Storage for this file as each version multiplied by its size. So in this case our file is roughly 25 * 39 MB towards the Storage allowance. That is a lot. 

So what can we do about it?

As usually there are a fair number of options:

A) Set up a Rentention policy that will delete some of the content. For some organizations this is not an option as per their Governance policies or fear that the policy might delete too much. 

B) Reduce the number of document versions saved  ( the default is 500 major versions). This will  often require that you have some kind of provision tools in place that will change the default value. The downside of this option is that you might be in a situation where you wish to restore an older version, but that version does not exist anymore.

C) Monitor the Site Collections for activity and enforce that the Owners of a Site Collection deletes any non essential documents once the Site Collection is no longer active. This Governance approach might work in some organizations, but I have yet to see it.

D) Monitor the Site Collections for activity and once it is no longer active the Archiving process starts. Depending on the requirements that could be something like:    





Step number 2 can be omitted but is there to ensure that it will be possible to locate any version of a given document should the need arise.

The reason for not deleting the entire Site Collection once the documents have been copied to cheaper storage is to ensure that the organization will still able to see the Site Collection and the content. Often the Site Collection was used in a project or similar and the organization needs to store that fact that this project once existed.

There is also possible to extend the process by deleting the Read Only Site Collection after a few months or years.  


If you are thinking "Well this might save us some SharePoint Storage, but I have no idea how to verify it", the PnP Script Samples is the place to go:

storage savings report


This script will output a report showing how much Storage you can save per site collection.


#SharingIsCaring