Staff sample using List Formatting

Today, we will review and use a List formatting, one of the features that SharePoint and apply it via PnP PowerShell. You can use it to apply to multiple sites with this automated process. The concept of this sample is that you have a Team inside your organization and you want to share the contacts of the persons on your SharePoint using a list. The PowerShell created will allow you to create all the required assets for using this sample.

Sample of each element of the list

All the required PowerShell, as well as the JSON file, will be available on the GitHub. The link for this sample is below. On this example, the PnP PowerShell will create the list, all the required columns the PowerShell and add the list formatting.

If you intend to check the examples of the List Formatting from the community, please verify the following link below:

One of the Columns is created using the XML because to get the Picture and additional information the User property requires a special ShowField . You just need to add content to the list to see the cards.

The first step is to create a file on your desktop which will contain the JSON that we will apply to the list. Create a copy of the JSON on the GitHub ViewFormatting.json and save it on your machine, it’ll be used by PowerShell to apply to the SharePoint list View.

$site     = "" #Site where the list will be created.
$nameList = "Project Staff" # Name of the List
$JsonPath = "C:\Users\USER\Desktop\ViewFormatting.txt" #Path to the Json File

$JSONFile = Get-Content $JsonPath 

$JSONFile | ConvertFrom-Json |Out-Null
$fieldXml = '<Field Type="User" Name="Person" DisplayName="Person" ID="{4dbd3482-af24-4319-913d-31e94b33912d}" Group="" Required="FALSE" SourceID="{56606dc3-9123-4fcb-a8be-5b20378eee20}" StaticName="Person" ColName="int1" RowOrdinal="0" EnforceUniqueValues="FALSE" ShowField="NameWithPictureAndDetails" UserSelectionMode="PeopleAndGroups" UserSelectionScope="0" Version="1" />'

Connect-PnPOnline -Url $site -UseWebLogin 

New-PnPList -Title $nameList -Template GenericList
Add-PnPField -List $nameList -DisplayName "LinkedIn" -InternalName "LinkedIn" -Type URL
Add-PnPField -List $nameList -DisplayName "Job Title" -InternalName "JobTitle" -Type Text
Add-PnPField -List $nameList -DisplayName "Phone Number" -InternalName "PhoneNumber" -Type Text
Add-PnPFieldFromXml -List $nameList -FieldXml $fieldXml

Set-PnPView -List $nameList -Identity "All Items" -Fields "Title","LinkedIn","JobTitle","PhoneNumber","Person"

$view = Get-PnPView -List $nameList -Identity "All Items" -Includes "CustomFormatter"
$view.CustomFormatter = $JSONFile
Invoke-PnPQuery -RetryWait 10


This sample is an adaption of this view formatting with the addition of the PowerShell to add quickly this to multiple sites –



  1. Amanda Bartlett said:

    I am incorporating your “Small Card” JSON from git hub for a list I have in SharePoint but I was wondering if there is a way to change the color of the mail icon. Right now it is blue and I would prefer it to be black or a custom color. Is this possible?

    July 20, 2020
    • David Ramalho said:

      Hi Amanda,

      Yes, you can add any color by changing the style where we’re using the icons. Eg. LinkedIn format:

      "children": [
      "elmType": "a",
      "style": {
      "cursor": "pointer",
      "attributes": {
      "class": "ms-bgColor-neutralLighterAlt ms-bgColor-neutralLight--hover ms-fontColor-themePrimary--hover",
      "iconName": "LinkedInLogo",
      "href": "=[$LinkedIn]",
      "title": "LinkedIn"

      July 23, 2020
  2. Manish Hira said:

    Awesome tips and book marked as a newbie SharePoint admin/dev.

    I am trying to do the same using your script and files with no changes, when I run the powershell script I get errors I’ve tried it multiple times on different lists in steps, all at one go, etc.

    Target is Sharepoint online where I am owner of a team/communication site only and working inside that environment.

    if all in one go – this error comes up when this command is run
    Set-PnPView -List $nameList -Identity “All Items” -Fields “Title”,”LinkedIn”,”JobTitle”,”PhoneNumber”,”Person”

    format-default : The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
    + CategoryInfo : NotSpecified: (:) [format-default], CollectionNotInitializedException
    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException,Microsoft.PowerShell.Commands.FormatDefaultCommand

    If I do it in stages, then it always fails on the last command … any ideas
    Invoke-PnPQuery -RetryWait 10
    Invoke-PnPQuery : An error occurred while parsing EntityName. Line 1, position 881.
    At line:4 char:1
    + Invoke-PnPQuery -RetryWait 10
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Invoke-PnPQuery], ServerException
    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,SharePointPnP.PowerShell.Commands.Base.InvokeQuery

    July 24, 2020
    • Manish Hira said:

      So this was resolved. I applied the JSON directly to the view in SPO and then it worked.

      But I can’t get the list/view to show more than 30 items even though I have configured the view item limit to show 100 items. Any idea where to look, thought it could be in the JSON but can’t find it.

      I also tried to add a grouping to the view to show employees by department and cards all went a bit crazy – that would be by next step if I can understand how to extend the JSON. Early days!

      July 24, 2020

Leave a Reply

Your email address will not be published. Required fields are marked *