powershell
powershell copied to clipboard
[BUG] NewDocumentTemplates not properly applied
Category
- [x] Bug
Describe the bug
When trying to modify a Custom Content Type from the "New" Menu, the NewDocumentTemplates Tag value is missing the Token Replacement.
Steps to reproduce
When I modify the New Menu via UI (Edit New Menu), I can see the modifications reflected in the Template File, once a template is extracted via Get-PnPSiteTemplate. That Template has Token Values set inside the <NewDocumentTemplates> Tag.
{"contentTypeId":"{listcontenttypeid:Documents,0x01200048B976BE692FB4429EFD78FB3407496E}
But when applying that Template with Invoke-PnPSiteTemplate, the "listcontenttypeid" Token is not replaced.
Reading the values from the SharePoint View via CSOM, after the Invoke-PnPSiteTemplate Command, shows that it did submit the value {listcontenttypeid:Documents,0x01200048B976BE692FB4429EFD78FB3407496E} instead of replacing it with the actual ID.
Expected behavior
When the Tag <NewDocumentTemplates> is automatically created by the Get Template Command, and Tokens are added to its value, then the Invoke Command should also be able to replace those before submitting.
Environment details (development & target environment)
PnP.PowerShell Version 1.10.0 SharePoint Online
Sorry, my bad, I wanted to post this to pnp.powershell not pnp.core :( Can someone move this please ?
@Leviani : moved.
Am I the only one with this issue, or is just no one modifying the "New" Menu setting via PnP ?
Hi @Leviani ,
The "Template Token" you are refering to isn't a Token, but a simple json string. -> The "listcontenttypeid" property is static, it will never be replaced with the actual listcontenttypeid.
As per your last question, many are most likely editing the "New" Menu Items Post-Provisioning, as SharePoint adds the ContentTypes you add to the list there by default.
What exactly are you trying to achieve ? Clean Up the Menu and have the default entries (Word, Excel, PowerPoint, etc.)? Add Custom Content Types ?
Hi @Studermarc,
as described above, the New Menu is modified via UI and then the Command Get-PnPSiteTemplate is executed to produce a local .XML file (removal of default CT with "visible":false).
If you open that file you will find the Line with the "listcontenttypeid" Token.
If you then use the exact same .xml File with the command Invoke-PnPSiteTemplate this automatically inserted Token is not replaced with the actual ID. It actually writes back towards SharePoint that whole json string. Other tokens like {site} or {listid} are replaced just fine.
Also If I modify the .XML by hand before running Invoke-PnPSiteTemplate and replace the Part {listcontenttypeid:Documents,0x01010066E49CA1E93AED47882CBBC1185F9B79}
with the actual ID it works as expected.
I found the portion looking for that Token in the old Repository here : https://github.com/pnp/PnP-Sites-Core/blob/master/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/TokenParser.cs
From a wild guess I would say that Get-PnPSiteTemplate does set {listcontenttypeid} inside the JSON String of the "NewDocumentTemplates", but the Invoke-PnPSiteTemplate does not remove it from there again.
Hi @Leviani ,
I took a closer look and there is as you mentionnen a "new" listcontenttypeid token in the exported site templates. I'm note sure when exactly this was introduced.
This issue is in my opinion directly related to the PnP Provisioning Engine, and not PnP PowerShell -> The PnP Core Repo was actually the right place to mention this.
Kind regards,
@jansenbe before we move this again, might you take a look at it and move it back to its original forum, if required ?
Hmm, so seems like this issue went through the cracks and no one is noticing it anymore :( @jansenbe