pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

Import-PnPTaxonomy, Creates wrong hierarchy when term contains comma #1761

Open jimmywim opened 5 years ago

jimmywim commented 5 years ago

Category

Environment

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 "

xmihux commented 4 years ago

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.

evlo commented 3 years ago

Another year and issue is still going strong.

jimmywim commented 3 years ago

@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

alexabramkin commented 3 years ago

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"

jimmywim commented 3 years ago

@alexabramkin What about when you want to include the Term ID too?

alexabramkin commented 3 years ago

@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

jimmywim commented 3 years ago

@alexabramkin Yep, see my original post at the top here, you include the ID when you export.

Export-PnPTaxonomy

alexabramkin commented 3 years ago

@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.

jimmywim commented 3 years ago

@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! :(

PaWeg commented 3 years ago

I had the same issue, but after updating the PNP Powershell module to the latest version (3.28.2012.0) it works fine.