So you want to manipulate the new Categories in the Events WebPart in SharePoint, here are few tips that might help you out!
First of all, you want to do your changes in the list itself, not on the site column. The site column itself won’t be helpful as you won’t find it unless you go to the content type first, and you’ll notice it’s in the Hidden category. So if you want to add your categories, you’ll need to do it on the list itself.
What do you do it if you provision the list as part of a provisioning process aka PnP Provisioning 😉 ? Well, if you run Get-PnPSiteTemplate and try to get the list, you won’t find the categories as part of the exported template. So if we want to change the categories, we’d do it with PnP PowerShell. I’m using PnP.PowerShell module (using PowerShell Core). In order to change the categories, you’d want to run these commands:
$ctx = Get-PnPContext $field = Get-PnPField -Identity "Category" -List "Events" $choiceField = New-Object Microsoft.SharePoint.Client.FieldChoice($ctx, $field.Path) $Ctx.Load($ChoiceField) Invoke-PnPQuery $ChoiceField.Choices = "Firm-wide" $ChoiceField.Choices += "Community" $ChoiceField.Choices += "Industry" $ChoiceField.UpdateAndPushChanges($True) Invoke-PnPQuery
Now one catch here is if you want to filter your Events WebPart to show only events of Category: Firm-wide.. when you filter by Firm-wide, you won’t get back any events back:
You would want to replace the – with space, so you’d filter by Firm wide:
Note if you’re using other WebParts that depend on SharePoint Search (ex: Highlighted Content WebPart), you’ll want to filter the same way by replacing the – with space.
Hope this post helps someone out there!
Picture By: Andrei Stratu @avantgardian