Introduction
In SharePoint, the list templates provide re-usability of columns without recreating it on every single site. For e.g. I have created a custom list which name is Project, in a SharePoint site collection with all relevant columns, Now I want this list structure in other site collections, without recreating the list on every single site.
Steps to save a list or library as a template
Step-1
Go to a SharePoint list, then navigate to list settings present under the list tab on the ribbon and then click on List Settings.
Step-2
Click on Save list as Template under Permissions and Management group.
Step-3
Provide template Filename and Template name. If you want to include the content, then select the check box, Click Ok
Step-4
Click OK on the success page.
How to download the list template
Step 1
Go to site setting, Click on List Templates under web Designers and Gallery.
Step 2
Click on Upload Document on the Files tab, then browse your file i.e-Demo.stop
You can also save the list template to your site by using PowerShell script,
- try {
- Add - Type - Path "..\Microsoft.SharePoint.Client.dll"
- Add - Type - Path "..\Microsoft.SharePoint.Client.Runtime.dll"
- $SiteUrl = Read - Host "Enter the SiteUrl"
- $UserName = Read - Host "Enter the username"
- $Password = Read - Host - AsSecureString Password
- $ctx = New - Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
- $Credentials = New - Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $Password)
- $ctx.Credentials = $credentials
- $Web = $Ctx.Web
- $site = $Ctx.Site
- $ctx.Load($web)
- $ctx.Load($site)
- $ctx.ExecuteQuery()
- $ListName = Read - Host "Enter the List Name"
- $list = $Ctx.Web.lists.GetByTitle($ListName)
- $FileName = Read - Host "Enter the File Name"
- $TemplateName = Read - Host "Enter the Template Name"
- $list.SaveAsTemplate($FileName, $TemplateName, "list template description", $true)
- $ctx.ExecuteQuery()
- Write - Host - ForegroundColor Green "Successfully save the list Template."
- sleep 10
- } catch {
- Write - Host - ForegroundColor Red 'Error ', ':'
- $Error[0].ToString();
- sleep 10
- }
Follow the below screenshot and enter the values into the parameters accordingly. Then you can get a successful message.
How to upload list template to another site
step 1
Go to site setting, Click on List Templates under web Designers and Gallery.
Step 2
Click on Upload Document in the Files tab, Then browse your file i.e-Demo.stp
Step 3
Save the list template.
Step 4
Go to Site contents, Click on New then select App.
Step 5
Select your template.
Step 6
Provide a list Name.
Step 7
Now your list added to the site successfully.
You can also add the list template to your site by using PowerShell script,
- try {
- Add - Type - Path "..\Microsoft.SharePoint.Client.dll"
- Add - Type - Path "..\Microsoft.SharePoint.Client.Runtime.dll"
- $SiteUrl = Read - Host "Enter the SiteUrl"
- $UserName = Read - Host "Enter the username"
- $Password = Read - Host - AsSecureString Password
- $ctx = New - Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
- $Credentials = New - Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $Password)
- $ctx.Credentials = $credentials
- $Web = $ctx.Web
- $site = $ctx.Site
- $ctx.Load($web)
- $ctx.Load($site)
- $ctx.ExecuteQuery()
- $Template = $site.GetCustomListTemplates($Web)
- $Lists = $ctx.Web.Lists
- $ctx.Load($Lists)
- $ctx.Load($Template)
- $ctx.ExecuteQuery()
- $TemplateName = Read - Host "Enter the Template Name"
- $ListName = Read - Host "Enter the List Name"
- $ListTemplate = $Template | where {
- $_.Name - eq $TemplateName
- }
- $List = $Lists | where {
- $_.Title - eq $ListName
- }
- If($List - eq $Null) {
- $ListCreation = New - Object Microsoft.SharePoint.Client.ListCreationInformation
- $ListCreation.Title = $ListName
- $ListCreation.ListTemplate = $ListTemplate
- $List = $Lists.Add($ListCreation)
- $ctx.ExecuteQuery()
- }
- Write - Host - ForegroundColor Green "Successfully Add the list."
- sleep 10
- } catch {
- Write - Host - ForegroundColor Red 'Error ', ':'
- $Error[0].ToString();
- sleep 10
- }
Follow the below screenshot and enter the values for the parameters accordingly. Then you can get a successful message.