Pnp-sites-core: Apply-PnPProvisioningTemplate: A duplicate field name was found.

Created on 30 Jul 2018  路  1Comment  路  Source: pnp/PnP-Sites-Core

I'm using PnP-Powershell repo and did a full export of the site A using Get-PnPProvisioningTemplate -Out "Template.xml" and tried to Apply this template on an empty new SP site using Apply-PnPProvisioningTemplate -Path "Template.xml"

Category

[X] Bug
[ ] Enhancement

Environment

[X] Office 365 / SharePoint Online
[ ] SharePoint 2016
[ ] SharePoint 2013

SharePointPnPPowerShellOnline 2.28.1807.0

I had the PnP tracing enabled to capture some debugging information:

powershell.exe Error: 0 : 2018-07-30 14:32:35.4648      [Fields]        [14]    [Error] Adding field {078f8554-9e40-44d3-bc57-867fd59b9a35} failed: A duplicate field name "Active" was found. :    at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
   at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
   at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryToServerAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientRuntimeContext.<ExecuteQueryAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientContext.<ExecuteQueryAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientContextExtensions.<ExecuteQueryImplementation>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay, String userAgent)
   at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectField.CreateField(Web web, XElement templateFieldElement, PnPMonitoredScope scope, TokenParser parser, String originalFieldXml)
   at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectField.ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)     3390ms    cd20b124-2138-472f-99e7-b45d9beba796
powershell.exe Information: 0 : 2018-07-30 14:32:35.4668        [Fields]        [14]    [Debug] Code execution scope ended      3393ms  cd20b124-2138-472f-99e7-b45d9beba796
powershell.exe Information: 0 : 2018-07-30 14:32:35.4678        [Provisioning]  [14]    [Debug] Code execution scope ended      24515ms cd20b124-2138-472f-99e7-b45d9beba796
Apply-PnPProvisioningTemplate : A duplicate field name "Active" was found.
At line:1 char:1
+ Apply-PnPProvisioningTemplate -Path "Template.xml"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Apply-PnPProvisioningTemplate], ServerException
    + FullyQualifiedErrorId : 
EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate

Template.zip

Most helpful comment

I was able to confirm that running the Apply command multiple times would throw this error since the custom columns are already created and it's not overwriting them. Is there any way to force overwrite the column creation process?

I simply deleted the custom columns and re-ran the Apply command and it went through. its strange though that after I did that cleanup now everytime I run the command it updates the columns and it doesn't crash anymore...

>All comments

I was able to confirm that running the Apply command multiple times would throw this error since the custom columns are already created and it's not overwriting them. Is there any way to force overwrite the column creation process?

I simply deleted the custom columns and re-ran the Apply command and it went through. its strange though that after I did that cleanup now everytime I run the command it updates the columns and it doesn't crash anymore...

Was this page helpful?
0 / 5 - 0 ratings