0

I am trying to duplicate a Classic Team Site in SharePoint Online with PowerShell PnP, and am having issues when applying the template to a new site using the Apply-PnPProvisioningTemplate command. That is:

Apply-PnPProvisioningTemplate -Path "C:\Temp\MySiteTemplate.xml"

This process chugs along fine for several minutes, but for whatever reason a number of my columns are getting created with an incorrect internal name. This doesn't happen to all columns.

For example, in my Template file, a field will be referred to with the following name, note the 0 at end of the name:

<FieldRef Name="Friday_x003A__x0020_Full_x0020_d0" />

This exact same name is used in various places throughout the template file.

However, when the field is created in the new SharePoint site, it is missing the 0 at the end, as evidenced with the following screenshot:

enter image description here

This version of the name (missing a character at the end) does not appear anywhere in the Template file, so I don't know why it is created like this in the destination site. This also causes the PnP command to crash halfway through with the following error, as the field names don't match anymore:

enter image description here

Is there something I'm doing wrong?

1 Answer 1

1

As a general rule: use only characters (not even numbers) in column names. Don't use spaces, dashes, underscores, or anything other than letters A-Z and a-z.

Anything else can lead to problems down the line.

Best practice is to use CamelCase to create the initial column name, for eg. FridayFullAbsence. After it has been created, you can always rename the column without affecting the internal name.

Special characters will be encoded and lead to longer internal column names that may even get cut off. These column names are hard to read for humans, and some procedures struggle to use them. I suspect that this is one such case.

It may be too late in your situation because the template site has already been built, but maybe you can replace these unwieldy columns in the template with shorter column names that are easier to process. You will need to create new columns and delete the old ones.

1
  • Thanks, I had a feeling this might be the case. Unfortunately I can't modify the source site, since it is currently running as a production application. Instead I am modifying the template itself to make sure the column names match in the destination, and the error doesn't occur. As to why this issue occurs in the first place, it seems to me that this is a bug in either SharePoint itself or in the PnP module (or perhaps both)...
    – DRVR
    Commented Sep 28, 2021 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.