PnP Provisioning Engine and external lists

MVP

Does the PnP provisioning engine support external lists?

 

My external list Client is exported using Get-PnPProvisioningTemplate without any error or warning messages. 

 

However when I apply the template  I'm getting an error. All other lists/libraries seem to work fine.

 

PowerShell_ISE.exe Information: 0 : 2017-02-06 21:13:48.5214 [List instances] [13] [Debug] Creating list Client failed: List 'Client' does not exist at site with URL '
Lists/Client'. : at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay)
at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectListInstance.CreateList(Web web, ListInstance list, TokenParser parser, PnPMonitoredScope scope, Bo
olean isNoScriptSite)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectListInstance.ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, Provision
ingTemplateApplyingInformation applyingInformation) 1044ms af22d037-7a45-4a0b-a0aa-38b9a19dea2e
PowerShell_ISE.exe Information: 0 : 2017-02-06 21:13:48.5244 [List instances] [13] [Debug] Code execution scope ended 1047ms af22d037-7a45-4a0b-a0aa-38b9a19dea2e
PowerShell_ISE.exe Information: 0 : 2017-02-06 21:13:48.5259 [Provisioning] [13] [Debug] Code execution scope ended 12482ms af22d037-7a45-4a0b-a0aa-38b9a19dea2e
Apply-PnPProvisioningTemplate : List 'Client' does not exist at site with URL 'Lists/Client'.
At line:1 char:1
+ Apply-PnPProvisioningTemplate -Web "clients/123456" -Path "C:\Workspa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Apply-PnPProvisioningTemplate], ServerException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate

4 Replies

It looks like your url to the list is incorrect. could you please upload the xml for it? i guess you miss a parameter or token.

 

The xml for the list in question looks like this:

 

<pnp:ListInstance Title="Client" Description="" DocumentTemplate="" OnQuickLaunch="true" TemplateType="600" Url="Lists/Client" MinorVersionLimit="0" MaxVersionLimit="0" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-9549-43f8-b978-e47e54a10600" EnableAttachments="false" EnableFolderCreation="false">
          <pnp:ContentTypeBindings>
            <pnp:ContentTypeBinding ContentTypeID="0x01" Default="true" />
          </pnp:ContentTypeBindings>
          <pnp:Views>
            <View Name="{3EA48E9F-5C84-4DBB-8921-B81105E6A2AF}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="ReadAllClient" Url="/clients/template/Lists/Client/ReadAllClient.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/generic.png?rev=44">
              <Method Name="ReadAllClient" />
              <Query>
                <OrderBy>
                  <FieldRef Name="ClientID" />
                </OrderBy>
              </Query>
              <ViewFields>
                <FieldRef Name="ClientID" ListItemMenu="TRUE" LinkToItem="TRUE" />
                <FieldRef Name="Name" />
                <FieldRef Name="Sector" />
                <FieldRef Name="Status" />
                <FieldRef Name="KeyContact" />
                <FieldRef Name="AddressID" />
              </ViewFields>
              <RowLimit Paged="TRUE">30</RowLimit>
              <Aggregations Value="Off" />
              <JSLink>clienttemplates.js</JSLink>
            </View>
          </pnp:Views>
          <pnp:Fields>
            <Field DisplayName="BDC Identity" Hidden="FALSE" Name="BdcIdentity" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="BdcIdentity" Type="Text" ReadOnly="TRUE" />
            <Field DisplayName="ClientID" Hidden="FALSE" Name="ClientID" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ClientID" Type="Integer" ReadOnly="TRUE" Required="TRUE" />
            <Field DisplayName="Name" Hidden="FALSE" Name="Name" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Name" Type="Text" />
            <Field DisplayName="Code" Hidden="FALSE" Name="Code" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Code" Type="Text" />
            <Field DisplayName="Sector" Hidden="FALSE" Name="Sector" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Sector" Type="Text" />
            <Field DisplayName="Status" Hidden="FALSE" Name="Status" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Status" Type="Text" />
            <Field DisplayName="KeyContact" Hidden="FALSE" Name="KeyContact" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="KeyContact" Type="Text" />
            <Field DisplayName="AddressID" Hidden="FALSE" Name="AddressID" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="AddressID" Type="Integer" Required="TRUE" />
          </pnp:Fields>
        </pnp:ListInstance>
        

The only major difference between this list and the other lists is the 

TemplateType="600"

 

Looking at the code:

 

{
                var listCreate = new ListCreationInformation();
                listCreate.Description = list.Description;
                listCreate.TemplateType = list.TemplateType;
                listCreate.Title = parser.ParseString(list.Title);

                // the line of code below doesn't add the list to QuickLaunch
                // the OnQuickLaunch property is re-set on the Created List object
                listCreate.QuickLaunchOption = list.OnQuickLaunch ? QuickLaunchOptions.On : QuickLaunchOptions.Off;

                listCreate.Url = parser.ParseString(list.Url);
                listCreate.TemplateFeatureId = list.TemplateFeatureID;

                createdList = web.Lists.Add(listCreate);
                createdList.Update();
            }
            web.Context.Load(createdList, l => l.BaseTemplate);
            web.Context.ExecuteQueryRetry();

The line 

 createdList = web.Lists.Add(listCreate);

 

is not creating the list as the exception is given on the following ExecuteQueryRetry.

 

could it be that your url should be like this: Snippet

{site}/Lists/MDL/AllItems.aspx

Hi @Deleted,

 

the internal lists have the same url in the tmeplate and they do work.

 

I've done some more investigation and for external lists we will need to store the datasource details and some other stuff in the PnP template

 

 

more details: https://github.com/SharePoint/PnP-Sites-Core/issues/1044

 

At the moment I'm planning to 

1. create the external list as dessribed here: https://pholpar.wordpress.com/2011/01/26/creating-external-lists-using-the-managed-client-object-model/

2. take the .xml template and remove any external lists from the template before applying it.

 

I don't really like this option as it may corrupt the templates ...