Forum Discussion

Nigel Witherdin's avatar
Nigel Witherdin
Iron Contributor
Mar 07, 2017

Error Provisioning a site containing Lookup column using PnP Provisioning Engine

Having an issue trying to use the PnP Provisioning Engine PowerShell cmdlets to template a site that contains Lookup columns. The site is an O365 site, and the commands I am using are:

 

Connect-SPOnline "https://scentregroup.sharepoint.com/sites/scgpmo"

Get-PnPProvisioningTemplate -Out c:\temp\pmo.xml -PersistBrandingFiles -Handlers Lists, ContentTypes, Fields, Files, Navigation, Pages, RegionalSettings, SiteSecurity, TermGroups, Workflows

Connect-SPOnline "https://scentregroup.sharepoint.com/sites/pmo_trial"
Apply-PnPProvisioningTemplate -Path c:\temp\pmo.xml -Handlers Lists, ContentTypes, Fields, Files, Navigation, Pages, RegionalSettings, SiteSecurity, TermGroups, Workflows
 

 

The "Apply-PnPProvisioningTemplate" fails with the error:

 

Apply-PnPProvisioningTemplate : The field was found invalid:  {{listid:PriorLookUpStratAlign1}

 

 

I believe the line in the pmo.xml file that is causing the issue is the first (of a few) lookup fields. I understand that the engine is using a token to represent the list id, which should be replaced with an actual list id when the list on the new site is actually created

 

<Field Type="Lookup" DisplayName="SCG_PMO_PriorityStrategicAlignment:Score1" List="{{listid:PriorLookUpStratAlign1}}" WebId="df9b6d5e-4f8b-4abe-99f9-1776e3928e22" ShowField="Score1" FieldRef="b1b6ed05-a2e1-4699-b3c8-12a1838c44ef" UnlimitedLengthInDocumentLibrary="FALSE" Group="SCG PMO" ID="{656200e0-d1ad-44f8-8c1a-e83a433f46b1}" SourceID="{df9b6d5e-4f8b-4abe-99f9-1776e3928e22}" StaticName="SCG_PMO_PriorityStrategicAlignment_x003a_Score1" Name="SCG_PMO_PriorityStrategicAlignment_x003A_Score1" ReadOnly="TRUE" />

Dont really understand why the "WebId" parameter is not also using some sort of token replacement logic?

 

Has anyone used the engine to template sites including lookup fields? If so, can you offer any advice as to where I am going wrong?

 

I have also attached the full pmo.xml file in case that helps

 

Thanks!

 

Nigel

3 Replies

  • I should mention that I am using the Feb 2017 release of the PnP PowerShell Online MSI (https://github.com/SharePoint/PnP-PowerShell/releases/download/2.12.1702.0/SharePointPnPPowerShellOnline.msi)

     

    Thanks again! 

    • paulpascha's avatar
      paulpascha
      Bronze Contributor

      I think the problem here is that the Field is being created without the List the lookup is referencing being available. There have been issues around this in the past, see the following issue in PnP repo for example:

      https://github.com/SharePoint/PnP/issues/906

       

      There seem to be more issues popping up recently around lookup fields. There is also this conversation describing the same issue:

      https://techcommunity.microsoft.com/t5/SharePoint-Developer/ApplyProvisioningTemplate-doesn-t-have-token-listid-Project-Team/m-p/49206#M1655

       

      I did some testing and I am able to reproduce your issue. I did the following basic steps

       

      • Create Team Site "A" and "B"
      • In Team Site "A" create List "My lookup list"
      • In Team Site "A" create Field "My Lookup field" referencing "My lookup list"
      • Save Team Site "A" as template using Get-PnPProvisioningTemplate
      • Apply template to Team Site "B" using Apply-PnPProvisioningTemplate

      I've submitted an issue in PnP here:

      https://github.com/SharePoint/PnP-Sites-Core/issues/1105

Resources