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.

  1. Download and extract the template from here
  2. 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
  3. Save the file
  4. Right click on it and choose Run with PowerShell
  5. Introduce your credentials and click OK
  6. 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.

The limitations

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.

  1. Open the JSON Definitions folder on the extracted zip
  2. Locate the file with the same name as listed above
  3. Open it and copy all the content
  4. Open your SharePoint site and go to the site contents
  5. Locate the list with the same name of the file
  6. Open the list
  7. On the right side of the command bar click on All Items and then Format this View
  8. Paste the JSON code and click Save
  9. 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.

Download Template
Explore Solution on GitHub


9 Responses to “How to easily deploy the list view formatting templates built by the community”

  1. Kelly

    September 9, 2019

    Right clicking and selecting ‘run with powershell’ is not prompting for credentials.

    Reply
    • João Ferreira

      September 9, 2019

      Hi Kelly,

      Can you please let me know if you see any script error when running the script?
      If the window closes to fast do the following:

      1 – Open the PowerShell console
      2 – Type cd followed by the path to the folder where you have the script
      3 – Type .\ApplyTemplate.ps1

      Let me know if there is any error message.

      Have a nice day 🙂

      Reply
      • Kelly

        September 13, 2019

        thanks for your reply. I’m getting the error message that the script cannot be loaded because running scripts is disabled on this system. (this is my personal machine so I’d love to get around this) I looked at https:/go.microsoft.com/fwlink/?LinkID=135170 but am not quite understanding exactly what i should be typing to override this restriction.

        Here are my execution policies:

        PS C:\WINDOWS\system32> Get-ExecutionPolicy
        Restricted
        PS C:\WINDOWS\system32> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        —– —————
        MachinePolicy Undefined
        UserPolicy Undefined
        Process Undefined
        CurrentUser Undefined
        LocalMachine Undefined

        Reply
        • João Ferreira

          September 13, 2019

          Hi Kelly,

          Open the powershell console and try to execute this command

          set-executionpolicy -executionpolicy unrestricted

          After it try to execute the script.
          Let me know how it went.

          Reply
  2. […] How to easily deploy the list view formatting templates built by the community – Joao Ferreira (BindTuning) […]

    Reply
  3. Pieter Temmerman

    September 27, 2019

    I had an issue with the “Apply-PnPProvisioningTemplate -Path listFormating.xml” command. I received on “object reference not set” error.

    To fix this I changed the line to:
    Apply-PnPProvisioningTemplate -Path listFormating.xml -TemplateId TEMPLATE-CA95271269984754886EDBC91C0AC0B6

    Greetings,
    Pieter

    Reply
    • João Ferreira

      September 27, 2019

      Hi Pieter,

      Thank you very much for providing a solution for this issue 🙂

      Have a nice day

      Reply
  4. Jonas Björkander

    February 11, 2020

    Will you update this with more samples?

    Reply
    • João Ferreira

      February 12, 2020

      Hi Jonas,

      Yes, I plan to update this with more samples and I even have new samples ready to publish.
      Unfortunately I don’t have time to do it before the end of March when I expect to return to the active blogging.

      Have a nice day 🙂

      Reply

Leave a Reply


Web developer focused on SharePoint branding, blogger, tech enthusiast. Travelling and sports are my addictions, knowledge and success are my daily motivations.