How to easily deploy the list view formatting templates built by the community
List view templates are JSON structures that allow you to customize the views on SharePoint lists creating HTML components that represent each item.
The SharePoint community has been sharing a lot of this templates on GitHub but if you want to try them on your own environment you will need create the lists with the same exact column names, add data to the lists and then apply the JSON to format the view.
With more than 20 templates available this can easily take a few hours to build all the lists and add all the templates.
In this post I’m providing a PnP Template that automates the deployment of the templates available on the GitHub repository, a demo environment can be setup without effort in less than 15 minutes.
The template creates all the lists, adds dummy data and adds the template to the default view of each list.
How to get started
To apply the template, you will need a blank communication site.
- Download and extract the template from here
- Edit the variables at the top of the file
- $siteURL – is the url to the communication site where the template will be applied
- $user – must be an email from a user that exists in the communication site, this is used by the views that format the Person column
- Save the file
- Right click on it and choose Run with PowerShell
- Introduce your credentials and click OK
- Get yourself a cup of coffee as it will take about 15 minutes to deploy all the lists ☕
How does it work
Once you get the PnP template deployed the site lading page will show 2 quick links web parts, the one on the left is the shortcut to all the SharePoint lists, the one on the right is the list to the repository on GitHub.
While building this template I’ve found a few limitations that tried to overcome with alternative methods but unfortunately there is one that was not possible. ☹ I did report it as a bug, now let’s get our fingers crossed to get a solution for it quickly.
There are a few list view templates that cannot be added through the PnP Template and all of them are related with the same bug, basically conditions that make use of the variable @now to format the items are being flagged as invalid JSON even though the template file is perfectly fine.
How to apply the missing templates
If you have looked to the PowerShell file you’ve probably noticed a few lines commented, those are the list templates that were not added automatically to your site.
- Birthday Row Format
- Conditional formatting based on date
- Contact Card Row Format
- Current User’s Rows
- Planner Inspired Task Cards
- Resource Catalog Sample
- Retail Account Sample
- Small Card
- User Profile Card
To get the missing templates on your site follow these steps for each item on the list above.
- Open the JSON Definitions folder on the extracted zip
- Locate the file with the same name as listed above
- Open it and copy all the content
- Open your SharePoint site and go to the site contents
- Locate the list with the same name of the file
- Open the list
- On the right side of the command bar click on All Items and then Format this View
- Paste the JSON code and click Save
- Repeat the process for all missing templates
Hope this helps you building a demo environment for the list view formatting, I’ll continue to update the template on GitHub to add more scenarios and to try to remove the current limitations.