1

I have created a simple list and saved as a template:

enter image description here

enter image description here

Unfortunately the template has the same ID as regular CustomList:

enter image description here

This is by design and - I suspect - cannot be changed (the property is read-only).

Now I would like to create a list from this template using CSOM and the following code:

$lci =New-Object Microsoft.SharePoint.Client.ListCreationInformation
  $lci.Description=$Description
$lci.Title=$Title
$lci.Templatetype=$TemplateType
$lci.TemplateFeatureID=$TemplateFeatureID

$list = $ctx.Web.Lists.Add($lci)
$ctx.Load($list)
try
 {

     $ctx.ExecuteQuery()
     Write-Host "List " $Title " has been added. "
 }
 catch [Net.WebException]
 { 
    Write-Host $_.Exception.ToString()
 }

The list gets created, but it doesn't have my custom view and the content (items I created). Basically it is not based on my template but the Custom List default template. Based on user21832's answer here this is by design.

So how can I create a list based on a template? Can I update somehow the ID? Can I use another function? Can I set the template's ID when creating it? When I use UI, the template is applied without issues. Any idea how does the code do it in the background?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.