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

$list = $ctx.Web.Lists.Add($lci)

     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 and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.