PnP-PowerShell
PnP-PowerShell copied to clipboard
Import-PnPTaxonomy, Creates wrong hierarchy when term contains comma
Category
- Bug
Environment
- Office 365 / SharePoint Online
- SharePoint 2016
- SharePoint 2013
If SharePoint on-premises, what's exact CU version: October 2018
Expected or Desired Behavior
Using an XML file from a previous run of Export-PnPTaxonomy
with -IncludeID, the imported hierarchy matches the original hierarchy exactly with the original IDs preserved for each level in the hierarchy.
Observed Behavior
Where a term contains a comma, the hierarchy is broken, so a child term is created with text after the comma. There is also a double quote character at the start of one term and at the end of the child term.
Steps to Reproduce
Create a group/termset/term hierarchy in SharePoint using the UI, and add a term with a comma. e.g.
My Group\My TermSet\My Term\Hello, World
Export-PnPTaxonomy -TermSetId {your termsite id} -Path terms.xml -IncludeID
Then
Import-PnPTaxonomy -Path .\termsxml
Note the resulting hierarchy, with the weird quote characters.
My Group\My TermSet\My Term\"Hello\World "
I'm having the same issue more than a year later. Are there any workarounds for this to import terms containing commas? I actually replaced commas with dots in the source file, then after import just renamed all terms back to the original names with commas.
Another year and issue is still going strong.
@evlo What version are you using? I forgot about this issue, and just tried to reproduce it with 3.23 and it works fine now.
EDIT: Forgot to Include IDs. Yep, issue still exists
3.26 version here and workaround that worked for me is to wrap any term with comma in it with double quotes, i.e.: term one|term two|"term, three"
@alexabramkin What about when you want to include the Term ID too?
@jimmywim did not have ids in the import (it is non SharePoint source), did not see it as an option in documentation either - do you have string example? I am willing to try it
@alexabramkin Yep, see my original post at the top here, you include the ID when you export.
@jimmywim Export-PnPTaxonomy works for export of terms and produces correct labels containing commas in the exported file. The file produced by Export-PnPTaxonomy with -IncludeID switch and then used with Import-PnPTaxonomy produces terms broken on commas. If your scenario requires export of terms containing commas along with IDs Export-PnPTermGroupToXml and Import-PnPTermGroupFromXml worked for me.
@alexabramkin Yep that's the workaround I ended up using.
I swear I saw a PR into PnP Sites Core (and PnPCore) that fixed this, however - but I can't find it! :(
I had the same issue, but after updating the PNP Powershell module to the latest version (3.28.2012.0) it works fine.