You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been having a challenge using templates in SharePoint and wanted to get some guidance on the appropriate method, I've made progress but getting stumped on the last stage.
We have a site setup that is a template site, within that site there are a number of document libraries and I want to template them so they can be created in future sites.
I have been able to generate a pnp file for the Document Libraries using this line:
Get-PnPSiteTemplate -Out .\PnPTemplates\SP.project.Lists.Test.pnp -Handlers Lists, ContentTypes, Fields -ListsToExtract "Test" -Force
But when we applied this template to a new site we were getting an error regarding template files, I can confirm this as by going into the PNP files and seeing a DocumentTemplate parameter pointing to "{site}/Records/Forms/template.dotx" - I can delete this value and the template gets applied without any issues.
Using this command I am able to pull the .dotx file and include it in the .pnp package: Add-PnPFileToSiteTemplate -Path ".\PnPTemplates\SP.project.Lists.Test.pnp" -SourceUrl "Test/Forms/template.dotx" -Container "Test/Forms/Document/"
But when I try and deploy the template to a library I'm getting the same template error about the template existing in the Forms directory: Write-Error: Template Error: Invalid template URL. The template must exist in the Forms directory of this document library. Create the template in the Forms directory, and then re-type the Web address. Note that you cannot move or copy a template into the Forms directory.
How do I get the file from the PNP package into the forms folder? Is this something that the Invoke-PnPSiteTemplate does automatically or do I need to add the file to the library before applying the template?
Just to add to this when I package up the PNP with the file I have taken a look at the xml and I can see the line that references the library with a template: <pnp:ListInstance Title="Test" Description="" **DocumentTemplate="{site}/Test/Forms/Document/template.dotx"** >
I can also the the file referenced: <pnp:File Src="Sharing/Forms/template.dotx" Folder="Sharing/Forms" Overwrite="true" Level="Published" />
The only obvious issue I can see is that the folder location is different, but I thought that was the Container parameter from the Add-PnPFileToSiteTemplate command.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been having a challenge using templates in SharePoint and wanted to get some guidance on the appropriate method, I've made progress but getting stumped on the last stage.
We have a site setup that is a template site, within that site there are a number of document libraries and I want to template them so they can be created in future sites.
I have been able to generate a pnp file for the Document Libraries using this line:
Get-PnPSiteTemplate -Out .\PnPTemplates\SP.project.Lists.Test.pnp -Handlers Lists, ContentTypes, Fields -ListsToExtract "Test" -ForceBut when we applied this template to a new site we were getting an error regarding template files, I can confirm this as by going into the PNP files and seeing a DocumentTemplate parameter pointing to "{site}/Records/Forms/template.dotx" - I can delete this value and the template gets applied without any issues.
Using this command I am able to pull the .dotx file and include it in the .pnp package:
Add-PnPFileToSiteTemplate -Path ".\PnPTemplates\SP.project.Lists.Test.pnp" -SourceUrl "Test/Forms/template.dotx" -Container "Test/Forms/Document/"But when I try and deploy the template to a library I'm getting the same template error about the template existing in the Forms directory:
Write-Error: Template Error: Invalid template URL. The template must exist in the Forms directory of this document library. Create the template in the Forms directory, and then re-type the Web address. Note that you cannot move or copy a template into the Forms directory.How do I get the file from the PNP package into the forms folder? Is this something that the Invoke-PnPSiteTemplate does automatically or do I need to add the file to the library before applying the template?
Just to add to this when I package up the PNP with the file I have taken a look at the xml and I can see the line that references the library with a template:
<pnp:ListInstance Title="Test" Description="" **DocumentTemplate="{site}/Test/Forms/Document/template.dotx"** >I can also the the file referenced:
<pnp:File Src="Sharing/Forms/template.dotx" Folder="Sharing/Forms" Overwrite="true" Level="Published" />The only obvious issue I can see is that the folder location is different, but I thought that was the Container parameter from the Add-PnPFileToSiteTemplate command.
Would appreciate any help/guidance that you have
Beta Was this translation helpful? Give feedback.
All reactions