Upload Custom List Template Sharepoint 365 Schema Elements
Create SharePoint list or library using PnP provisioning template in Ability Automate¶
This article volition evidence how to create a custom SharePoint list or library using PnP provisioning template. You can use this arroyo to create lists or libraries of whatever complexity in SharePoint. For case, y'all may desire to create an employees list with a fix of predefined columns for your team. We volition do it below.
PnP template is an XML file that contains a clarification of SharePoint entities (lists, libraries, pages, etc.) that will be created. You can create own XML template for your SharePoint list or library. Then utilise the Provision PnP template to SharePoint activity from Plumsail Actions to apply PnP templates to your SharePoint sites using Power Automate (Microsoft Menstruation) or Azure Logic Apps.
If you are new to Plumsail Actions, follow this getting started teaching.
First of all, we need to create a PnP provisioning template for our listing. Let united states of america say nosotros accept the employees listing:
There are two ways to create a PnP template:
-
Write a PnP template manually and provision a uncomplicated listing - It is useful for simple lists without custom views or content types.
-
Get a PnP template from an existing list and provision a complex list - Information technology is useful for complex lists with content types, views, site columns.
You will observe the description of both approaches below. Pick the one that you lot similar more.
Write a PnP template manually and provision a uncomplicated listing¶
Note
Our activity supports the PnP template schema V202002 (or earlier).
This approach is useful for creation of simple lists or document libraries without custom content types, site columns, etc. Below you can run across instance of a template for simple employees list:
<?xml version="ane.0"?> <pnp:Provisioning xmlns:pnp= "http://schemas.dev.office.com/PnP/2018/07/ProvisioningSchema" > <pnp:Preferences Generator= "OfficeDevPnP.Cadre, Version=iii.7.1903.0, Civilization=neutral, PublicKeyToken=5e633289e95c321a" /> <pnp:Templates ID= "CONTAINER-TEMPLATE-C1181F206BE84C09AAAC4B3CB21FBE32" > <pnp:ProvisioningTemplate ID= "TEMPLATE-C1181F206BE84C09AAAC4B3CB21FBE32" Version= "i" Scope= "Web" > <pnp:Lists> <pnp:ListInstance Championship= "Employees List3" TemplateType= "100" Url= "Lists/EmployeesList3" EnableFolderCreation= "false" > <pnp:ContentTypeBindings> <pnp:ContentTypeBinding ContentTypeID= "0x01" Default= "true" /> <pnp:ContentTypeBinding ContentTypeID= "0x0120" /> </pnp:ContentTypeBindings> <pnp:Views> <View Name= "AllItems" DefaultView= "TRUE" Type= "HTML" DisplayName= "All Items" Level= "ane" BaseViewID= "i" ContentTypeID= "0x" > <Query> <OrderBy> <FieldRef Name= "ID" /> </OrderBy> </Query> <ViewFields> <FieldRef Name= "LinkTitle" /> <FieldRef Name= "Director" /> <FieldRef Proper name= "PhotoUrl" /> <FieldRef Name= "JobTitle" /> <FieldRef Proper noun= "Department" /> <FieldRef Name= "Office" /> <FieldRef Proper noun= "WorkPhone" /> <FieldRef Name= "WorkEmail" /> </ViewFields> <RowLimit Paged= "True" >30</RowLimit> </View> </pnp:Views> <pnp:Fields> <Field ID= "{4512a091-1007-4cd9-900b-411f01f2b119}" DisplayName= "Manager" Name= "Director" Type= "Text" /> <Field ID= "{2980c003-7607-46de-8676-6c64cd2a3431}" DisplayName= "Photo URL" Name= "PhotoUrl" Type= "Text" /> <Field ID= "{50ef44ad-091f-4955-a957-b0fb9b42811b}" DisplayName= "Job Title" Name= "JobTitle" Type= "Text" /> <Field ID= "{346ada44-fd5f-4ed2-85af-d9be52a79f51}" DisplayName= "Department" Proper noun= "Department" Blazon= "Text" /> <Field ID= "{f3340208-afe4-404e-bbe3-86edf38e4e52}" DisplayName= "Office" Proper name= "Office" Blazon= "Text" /> <Field ID= "{d9c0a3c9-b591-4646-92d2-95ebc693bed9}" DisplayName= "Work Phone" Name= "WorkPhone" Type= "Text" /> <Field ID= "{8c612e69-e32d-4d34-9e38-32fadedc9575}" DisplayName= "Piece of work Email" Proper noun= "WorkEmail" Type= "Text" /> </pnp:Fields> </pnp:ListInstance> </pnp:Lists> </pnp:ProvisioningTemplate> </pnp:Templates> </pnp:Provisioning> Let us review what you can change in the template.
<pnp:ListInstance> tag¶
<pnp:ListInstance> tag represents a list. You tin can change listing championship ( Title ) and list URL ( Url ). Also, if y'all want to create a document library, you need to change TemplateType to 101 instead of 100 .
You can detect all the available template types in the official Microsoft documentation.
<Field> tag¶
<pnp:Field> tag represents a column in your list. You tin add new fields by adding new tags similar this:
<pnp:Fields> <Field ID= "{4512a091-1007-4cd9-900b-411f01f2b119}" DisplayName= "Manager" Proper noun= "Managing director" Type= "Text" /> ... </pnp:Fields> -
DisplayNameis a brandish name of the field. -
Nameis an internal name of the field. -
Typerepresents a type of the field. You tin can find all the available types in this article. -
IDis a unique ID of the field. Y'all can put hither unique GUID or make full information technology dynamically in your Power Automate (Microsoft Flow). Encounter the instance below.
<FieldRef> tag under <ViewFields>¶
<FieldRef> tag under <ViewFields> represents a field in a list view. If you desire to add your new field in the list view, create the <FieldRef> tag for information technology:
<ViewFields> <FieldRef Name= "Manager" /> ... </ViewFields> For more data about tags available in PnP templates review PnP provisioning schema.
Case of Power Automate (Microsoft Flow)¶
Re-create and paste your template into Provision PnP template to SharePoint activeness in your Flow:
You need to replace all values for Field IDs using Power Automate (Microsoft Flow) expressions like on the screenshot above. Information technology volition ensure that your fields will ever have unique IDs.
This approach is useful when you want to create simple SharePoint lists or document libraries. If you take a complex list with many views yous may consider another choice with creating your template from an existing list using PowerShell. For more data read below.
Get a PnP template from an existing list and provision a complex list¶
PnP PowerShell allows y'all to execute various commands for manipulating SharePoint, including grabbing of a template from a SharePoint site.
Showtime of all, y'all need to install PnP PowerShell. Follow the installation teaching. Then connect to your SharePoint site. Execute the command beneath and specify your own URL for the site where your Modern folio is stored:
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/mysite" Unfortunately, there are no PnP PowerShell commands for getting a template from a single list. You could execute this control:
Go-PnPProvisioningTemplate -Out "template.xml" -Handlers Lists -Schema V202002 Note
Yous should specify the schema version explicitly to ensure that it is supported by our service ( V202002 or earlier).
But this command creates a template for all lists and libraries on your site. If it is your case, you can use the code above. Otherwise, you need a workaround.
The script below is the workaround. It volition help you lot to get a template from a single listing:
$listName = "Employees" ; $outputTemplateFileName = "template.xml" ; $template = Get-PnPProvisioningTemplate -OutputInstance -Handlers Lists -Schema V202002 $listTemplate = $template . Lists | Where-Object { $_ . Title -eq $listName } $template . Lists . Clear () $template . Lists . Add together ( $listTemplate ) Save-PnPProvisioningTemplate -InputInstance $template -Out $outputTemplateFileName This scripts gets a template for a unmarried listing. Let's have a closer look:
-
In the first line nosotros specify championship of the list. You need to supercede "Employees" past the name of your list.
-
In the 2d line, we specify the location of the output template file. You can change "template.xml" to another path.
-
The residue of the lawmaking takes a template for all lists of the site. Then it removes all the lists except the one we need.
One time you executed the script, you volition have the template for your specific listing or document library.
Annotation
This script gets a template of a list without external references like content types, site columns, etc. If you need to include them into the template, you lot need to alter the PowerShell script or do it manually in the XML.
That is all. Now y'all can salve the template file somewhere in your SharePoint and use this file as a template in the Provision PnP template to SharePoint action:
If you haven't used Plumsail Deportment however, registering an business relationship would be the outset step. Information technology is quite like shooting fish in a barrel to get started.
Hint
You lot may also exist interested in this article explaining how to provision site using PnP template.
weatherfordyoulded.blogspot.com
Source: https://plumsail.com/docs/actions/v1.x/flow/how-tos/sharepoint/create-list-library-pnp.html
Enregistrer un commentaire for "Upload Custom List Template Sharepoint 365 Schema Elements"