Error Provisioning a site containing Lookup column using PnP Provisioning Engine

%3CLINGO-SUB%20id%3D%22lingo-sub-51321%22%20slang%3D%22en-US%22%3EError%20Provisioning%20a%20site%20containing%20Lookup%20column%20using%20PnP%20Provisioning%20Engine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-51321%22%20slang%3D%22en-US%22%3E%3CP%3EHaving%20an%20issue%20trying%20to%20use%20the%20PnP%20Provisioning%20Engine%20PowerShell%20cmdlets%20to%20template%20a%20site%20that%20contains%20Lookup%20columns.%20The%20site%20is%20an%20O365%20site%2C%20and%20the%20commands%20I%20am%20using%20are%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CPRE%3EConnect-SPOnline%20%22https%3A%2F%2Fscentregroup.sharepoint.com%2Fsites%2Fscgpmo%22%0A%0AGet-PnPProvisioningTemplate%20-Out%20c%3A%5Ctemp%5Cpmo.xml%20-PersistBrandingFiles%20-Handlers%20Lists%2C%20ContentTypes%2C%20Fields%2C%20Files%2C%20Navigation%2C%20Pages%2C%20RegionalSettings%2C%20SiteSecurity%2C%20TermGroups%2C%20Workflows%0A%0AConnect-SPOnline%20%22https%3A%2F%2Fscentregroup.sharepoint.com%2Fsites%2Fpmo_trial%22%0AApply-PnPProvisioningTemplate%20-Path%20c%3A%5Ctemp%5Cpmo.xml%20-Handlers%20Lists%2C%20ContentTypes%2C%20Fields%2C%20Files%2C%20Navigation%2C%20Pages%2C%20RegionalSettings%2C%20SiteSecurity%2C%20TermGroups%2C%20Workflows%3C%2FPRE%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20%22Apply-PnPProvisioningTemplate%22%20fails%20with%20the%26nbsp%3Berror%3A%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EApply-PnPProvisioningTemplate%20%3A%20The%20field%20was%20found%20invalid%3A%20%26nbsp%3B%7B%7Blistid%3APriorLookUpStratAlign1%7D%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20believe%20the%20line%20in%20the%20pmo.xml%20file%20that%20is%20causing%20the%20issue%20is%20the%20first%20(of%20a%20few)%20lookup%20fields.%20I%20understand%20that%20the%20engine%20is%20using%20a%20token%20to%20represent%20the%20list%20id%2C%20which%20should%20be%20replaced%20with%20an%20actual%20list%20id%26nbsp%3Bwhen%20the%20list%20on%20the%20new%20site%20is%20actually%20created%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%26lt%3BField%20Type%3D%22Lookup%22%20DisplayName%3D%22SCG_PMO_PriorityStrategicAlignment%3AScore1%22%20List%3D%22%7B%7Blistid%3APriorLookUpStratAlign1%7D%7D%22%20WebId%3D%22df9b6d5e-4f8b-4abe-99f9-1776e3928e22%22%20ShowField%3D%22Score1%22%20FieldRef%3D%22b1b6ed05-a2e1-4699-b3c8-12a1838c44ef%22%20UnlimitedLengthInDocumentLibrary%3D%22FALSE%22%20Group%3D%22SCG%20PMO%22%20ID%3D%22%7B656200e0-d1ad-44f8-8c1a-e83a433f46b1%7D%22%20SourceID%3D%22%7Bdf9b6d5e-4f8b-4abe-99f9-1776e3928e22%7D%22%20StaticName%3D%22SCG_PMO_PriorityStrategicAlignment_x003a_Score1%22%20Name%3D%22SCG_PMO_PriorityStrategicAlignment_x003A_Score1%22%20ReadOnly%3D%22TRUE%22%20%2F%26gt%3B%3C%2FPRE%3E%3CP%3EDont%20really%20understand%20why%20the%20%22WebId%22%20parameter%20is%20not%20also%20using%20some%20sort%20of%20token%20replacement%20logic%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EHas%20anyone%20used%20the%20engine%20to%20template%20sites%20including%20lookup%20fields%3F%20If%20so%2C%20can%20you%20offer%20any%20advice%20as%20to%20where%20I%20am%20going%20wrong%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20have%20also%20attached%20the%20full%20pmo.xml%20file%20in%20case%20that%20helps%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EThanks!%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ENigel%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-51321%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-52269%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20Provisioning%20a%20site%20containing%20Lookup%20column%20using%20PnP%20Provisioning%20Engine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-52269%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20reply%20Paul%20-%20lets%20see%20what%20happens.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-51353%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20Provisioning%20a%20site%20containing%20Lookup%20column%20using%20PnP%20Provisioning%20Engine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-51353%22%20slang%3D%22en-US%22%3E%3CP%3EI%20think%20the%20problem%20here%20is%20that%20the%20Field%20is%20being%20created%20without%20the%20List%20the%20lookup%20is%20referencing%20being%20available.%20There%20have%20been%20issues%20around%20this%20in%20the%20past%2C%20see%20the%20following%20issue%20in%20PnP%20repo%20for%20example%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP%2Fissues%2F906%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP%2Fissues%2F906%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20seem%20to%20be%20more%20issues%20popping%20up%20recently%20around%20lookup%20fields.%20There%20is%20also%20this%20conversation%20describing%20the%20same%20issue%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FSharePoint-Developer%2FApplyProvisioningTemplate-doesn-t-have-token-listid-Project-Team%2Fm-p%2F49206%23M1655%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FSharePoint-Developer%2FApplyProvisioningTemplate-doesn-t-have-token-listid-Project-Team%2Fm-p%2F49206%23M1655%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20did%20some%20testing%20and%20I%20am%20able%20to%20reproduce%20your%20issue.%20I%20did%20the%20following%20basic%20steps%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3ECreate%20Team%20Site%20%22A%22%20and%20%22B%22%3C%2FLI%3E%3CLI%3EIn%20Team%20Site%20%22A%22%20create%20List%20%22My%20lookup%20list%22%3C%2FLI%3E%3CLI%3E%3CSPAN%3EIn%20Team%20Site%20%22A%22%20cr%3C%2FSPAN%3Eeate%20Field%20%22My%20Lookup%20field%22%20referencing%20%22My%20lookup%20list%22%3C%2FLI%3E%3CLI%3ESave%20Team%20Site%20%22A%22%20as%20template%20using%20Get-PnPProvisioningTemplate%3C%2FLI%3E%3CLI%3EApply%20template%20to%20Team%20Site%20%22B%22%20using%20Apply-PnPProvisioningTemplate%3C%2FLI%3E%3C%2FUL%3E%3CP%3EI've%20submitted%20an%20issue%20in%20PnP%20here%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Sites-Core%2Fissues%2F1105%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Sites-Core%2Fissues%2F1105%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-51323%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20Provisioning%20a%20site%20containing%20Lookup%20column%20using%20PnP%20Provisioning%20Engine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-51323%22%20slang%3D%22en-US%22%3E%3CP%3EI%20should%20mention%20that%20I%20am%20using%20the%20Feb%202017%20release%20of%20the%20PnP%20PowerShell%20Online%20MSI%20(%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%2Freleases%2Fdownload%2F2.12.1702.0%2FSharePointPnPPowerShellOnline.msi%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3ESharePointPnPPowerShellOnline.msi%3C%2FA%3E%3C%2FSTRONG%3E)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again!%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

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
Highlighted

I should mention that I am using the Feb 2017 release of the PnP PowerShell Online MSI (SharePointPnPPowerShellOnline.msi)

 

Thanks again! 

Highlighted

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

 

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

Highlighted

Thanks for the reply Paul - lets see what happens.