How to upload a list template to a SharePoint site.

A hidden gem within SharePoint is the ability to upload a list template to a SharePoint site. Once this list lives within SharePoint, it can be replicated via the Microsoft Teams “Lists” functionality. The purpose of this blog post is to demonstrate how to upload a SharePoint List XML Template to a SharePoint site.

The following technologies will be used:

  • SharePoint
  • SharePoint List XML File
  • PowerShell PnP Module

SharePoint List Template

Below is an image of a Project Phase list using Project Management Institute best practices.

Here is the XML format for this list. Save it as “template.xml”.

<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2020/02/ProvisioningSchema">
  <pnp:Preferences Generator="OfficeDevPnP.Core, Version=3.19.2003.0, Culture=neutral, PublicKeyToken=5e633289e95c321a" />
  <pnp:Templates ID="CONTAINER-TEMPLATE-BC56B32FD93543FF86B70EA0E197CCEE">
    <pnp:ProvisioningTemplate ID="TEMPLATE-BC56B32FD93543FF86B70EA0E197CCEE" Version="1" BaseSiteTemplate="GROUP#0" Scope="RootSite">
      <pnp:SiteFields>
        <Field ID="{3A8EE3F8-166B-4394-B3E2-E98DCF86A847}" Name="A2ODMountCount" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="A2ODMountCount" Hidden="TRUE" Group="_Hidden" ReadOnly="TRUE" Type="Lookup" List="Docs" ShowField="A2ODMountCount" DisplayName="A2OD Mount Count" FromBaseType="TRUE" DisplaceOnUpgrade="TRUE" FieldRef="ID" JoinColName="DoclibRowId" JoinRowOrdinal="0" JoinType="INNER" />
      </pnp:SiteFields>
      <pnp:Lists>
        <pnp:ListInstance Title="Project Phase List" Description="" DocumentTemplate="" OnQuickLaunch="true" TemplateType="100" Url="Lists/Project Phase List" MinorVersionLimit="0" MaxVersionLimit="0" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-de22-43b2-a848-c05709900100" EnableFolderCreation="false" DefaultDisplayFormUrl="{site}/Lists/Project Phase List/DispForm.aspx" DefaultEditFormUrl="{site}/Lists/Project Phase List/EditForm.aspx" DefaultNewFormUrl="{site}/Lists/Project Phase List/NewForm.aspx" ImageUrl="/_layouts/15/images/itgen.png?rev=47" IrmExpire="false" IrmReject="false" IsApplicationList="false" ValidationFormula="" ValidationMessage="">
          <pnp:ContentTypeBindings>
            <pnp:ContentTypeBinding ContentTypeID="0x01" Default="true" />
            <pnp:ContentTypeBinding ContentTypeID="0x0120" />
          </pnp:ContentTypeBindings>
          <pnp:Views>
            <View Name="{4E9459AF-AAF2-4C4D-8C27-B56BFBF10F4A}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All Items" Url="{site}/Lists/Project Phase List/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/generic.png?rev=47">
              <Query>
                <OrderBy>
                  <FieldRef Name="ID" />
                </OrderBy>
              </Query>
              <ViewFields>
                <FieldRef Name="LinkTitle" />
                <FieldRef Name="Description" />
                <FieldRef Name="Status" />
                <FieldRef Name="PredictedStartDate" />
                <FieldRef Name="ActualStartDate" />
                <FieldRef Name="PredictedEndDate" />
                <FieldRef Name="ActualEndDate" />
                <FieldRef Name="AssignedTo" />
              </ViewFields>
              <RowLimit Paged="TRUE">30</RowLimit>
              <JSLink>clienttemplates.js</JSLink>
              <CustomFormatter />
            </View>
          </pnp:Views>
          <pnp:Fields>
            <Field AppendOnly="FALSE" DisplayName="Description" Format="Dropdown" IsolateStyles="FALSE" Name="Description" RichText="FALSE" RichTextMode="Compatible" Title="Description" Type="Note" ID="{4fe7eda7-2264-4359-b37b-1a38ca7f88c9}" SourceID="{{listid:Project Phase List}}" StaticName="Description" ColName="ntext2" RowOrdinal="0" />
            <Field CustomFormatter="{&quot;elmType&quot;:&quot;div&quot;,&quot;style&quot;:{&quot;flex-wrap&quot;:&quot;wrap&quot;,&quot;display&quot;:&quot;flex&quot;},&quot;children&quot;:[{&quot;elmType&quot;:&quot;div&quot;,&quot;style&quot;:{&quot;box-sizing&quot;:&quot;border-box&quot;,&quot;padding&quot;:&quot;4px 8px 5px 8px&quot;,&quot;display&quot;:&quot;flex&quot;,&quot;border-radius&quot;:&quot;16px&quot;,&quot;height&quot;:&quot;24px&quot;,&quot;align-items&quot;:&quot;center&quot;,&quot;white-space&quot;:&quot;nowrap&quot;,&quot;overflow&quot;:&quot;hidden&quot;,&quot;margin&quot;:&quot;4px 4px 4px 4px&quot;},&quot;attributes&quot;:{&quot;class&quot;:{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;Blocked&quot;]},&quot;sp-css-backgroundColor-errorBackground50&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;In Progress&quot;]},&quot;sp-css-backgroundColor-warningBackground50&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;Complete&quot;]},&quot;sp-css-backgroundColor-successBackground50&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;&quot;]},&quot;&quot;,&quot;sp-field-borderAllRegular sp-field-borderAllSolid sp-css-borderColor-neutralSecondary&quot;]}]}]}]}},&quot;children&quot;:[{&quot;elmType&quot;:&quot;span&quot;,&quot;style&quot;:{&quot;line-height&quot;:&quot;16px&quot;,&quot;height&quot;:&quot;14px&quot;},&quot;attributes&quot;:{&quot;iconName&quot;:{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;Blocked&quot;]},&quot;&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;In Progress&quot;]},&quot;&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;Complete&quot;]},&quot;&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;&quot;]},&quot;&quot;,&quot;&quot;]}]}]}]}}},{&quot;elmType&quot;:&quot;span&quot;,&quot;style&quot;:{&quot;overflow&quot;:&quot;hidden&quot;,&quot;text-overflow&quot;:&quot;ellipsis&quot;,&quot;padding&quot;:&quot;0 3px&quot;},&quot;txtContent&quot;:&quot;@currentField&quot;,&quot;attributes&quot;:{&quot;class&quot;:{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;Blocked&quot;]},&quot;&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;In Progress&quot;]},&quot;&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;Complete&quot;]},&quot;&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;@currentField&quot;,&quot;&quot;]},&quot;&quot;,&quot;&quot;]}]}]}]}}}]}],&quot;templateId&quot;:&quot;BgColorChoicePill&quot;}" DisplayName="Status" FillInChoice="FALSE" Format="Dropdown" Name="Status" Title="Status" Type="Choice" ID="{2aeb4978-2a95-4a93-bf71-5b64b0d4a57b}" SourceID="{{listid:Project Phase List}}" StaticName="Status" ColName="nvarchar4" RowOrdinal="0">
              <CHOICES>
                <CHOICE>Blocked</CHOICE>
                <CHOICE>In Progress</CHOICE>
                <CHOICE>Complete</CHOICE>
              </CHOICES>
              <Default>Blocked</Default>
            </Field>
            <Field DisplayName="Predicted Start Date" FriendlyDisplayFormat="Relative" Format="DateOnly" Name="PredictedStartDate" Title="Predicted Start Date" Type="DateTime" ID="{09b7083f-8ee2-449f-b575-568260012f59}" SourceID="{{listid:Project Phase List}}" StaticName="PredictedStartDate" ColName="datetime1" RowOrdinal="0" />
            <Field DisplayName="Actual Start Date" FriendlyDisplayFormat="Relative" Format="DateOnly" Name="ActualStartDate" Title="Actual Start Date" Type="DateTime" ID="{375a1edb-0f58-42ed-906e-0f1627272486}" SourceID="{{listid:Project Phase List}}" StaticName="ActualStartDate" ColName="datetime2" RowOrdinal="0" />
            <Field DisplayName="Predicted End Date" FriendlyDisplayFormat="Relative" Format="DateOnly" Name="PredictedEndDate" Title="Predicted End Date" Type="DateTime" ID="{85dd6df6-498e-4bbc-ab51-cd6c8b1ffce2}" SourceID="{{listid:Project Phase List}}" StaticName="PredictedEndDate" ColName="datetime3" RowOrdinal="0" />
            <Field DisplayName="Actual End Date" FriendlyDisplayFormat="Relative" Format="DateOnly" Name="ActualEndDate" Title="Actual End Date" Type="DateTime" ID="{a8121385-1197-43b8-b3f0-bbf1e013d9b3}" SourceID="{{listid:Project Phase List}}" StaticName="ActualEndDate" ColName="datetime4" RowOrdinal="0" />
            <Field DisplayName="Assigned To" Format="Dropdown" List="UserInfo" Mult="TRUE" Name="AssignedTo" Title="Assigned To" Type="UserMulti" UserSelectionMode="0" UserSelectionScope="0" ID="{de102982-fc9a-4eee-a465-d203397e2f04}" SourceID="{{listid:Project Phase List}}" StaticName="AssignedTo" ColName="int1" RowOrdinal="0" />
          </pnp:Fields>
          <pnp:Webhooks>
            <pnp:Webhook ServerNotificationUrl="https://southcentralus1.pushnp.svc.ms/notifications?token=1f93f348-2718-4619-b394-f593e4cbb62d" ExpiresInDays="1" />
          </pnp:Webhooks>
        </pnp:ListInstance>
      </pnp:Lists>
    </pnp:ProvisioningTemplate>
  </pnp:Templates>
</pnp:Provisioning>

Uploading a SharePoint List

The next steps are to run a PnP PowerShell script to upload the SharePoint list to the SharePoint site. Be sure to ensure the following steps are complete:

  • This script will only work if you have admin-level rights to the SharePoint tenant.
  • The “template.xml” file should be in the same folder from which this PowerShell script is ran.
$VarSharePointURL = "https://tenant.sharepoint.com/"
Connect-PnPOnline -Url $VarSharePointURL -UseWebLogin
Apply-PnPProvisioningTemplate -Path .\template.xml

Run the PowerShell script and the list will upload to the SharePoint site:

Image of newly uploaded SharePoint list.

Contact Kiefer Consulting to learn more about Microsoft Lists and how to leverage SharePoint to manage projects. We look forward to talking to you.

Archives

Follow Us

Leave a Comment

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