0

I have a Shared Documents list that I add to a page:

  <pnp:WebPart Title="Documents" Zone="Body" Order="1">
    <pnp:Contents>
      <webParts>
        <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
          <metaData>
            <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
            <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
          </metaData>
          <data>
            <properties>
              <property name="ShowWithSampleData" type="bool">False</property>
              <property name="Default" type="string" />
              <property name="NoDefaultStyle" type="string" />
              <property name="CacheXslStorage" type="bool">True</property>
              <property name="ViewContentTypeId" type="string" />
              <property name="XmlDefinitionLink" type="string" />
              <property name="ManualRefresh" type="bool">False</property>
              <property name="ListUrl" type="string" null="true" />
              <property name="ListId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">{listid:Documents}</property>
              <property name="EnableOriginalValue" type="bool">False</property>
              <property name="Direction" type="direction">NotSet</property>
              <property name="ServerRender" type="bool">False</property>
              <property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Html, TabularView, Hidden, Mobile</property>
              <property name="AllowConnect" type="bool">True</property>
              <property name="ListName" type="string">{{listid:Documents}}</property>
              <property name="ListDisplayName" type="string" null="true" />
              <property name="AllowZoneChange" type="bool">True</property>
              <property name="ChromeState" type="chromestate">Normal</property>
              <property name="DisableSaveAsNewViewButton" type="bool">False</property>
              <property name="ViewFlag" type="string" />
              <property name="DataSourceID" type="string" />
              <property name="ExportMode" type="exportmode">All</property>
              <property name="AutoRefresh" type="bool">False</property>
              <property name="FireInitialRow" type="bool">True</property>
              <property name="AllowEdit" type="bool">True</property>
              <property name="Description" type="string" />
              <property name="HelpMode" type="helpmode">Modeless</property>
              <property name="BaseXsltHashKey" type="string" null="true" />
              <property name="AllowMinimize" type="bool">True</property>
              <property name="CacheXslTimeOut" type="int">86400</property>
              <property name="ChromeType" type="chrometype">Default</property>
              <property name="Xsl" type="string" null="true" />
              <property name="JSLink" type="string" null="true" />
              <property name="CatalogIconImageUrl" type="string">/_layouts/15/images/itdl.png?rev=44</property>
              <property name="SampleData" type="string" null="true" />
              <property name="UseSQLDataSourcePaging" type="bool">True</property>
              <property name="TitleIconImageUrl" type="string" />
              <property name="PageSize" type="int">-1</property>
              <property name="ShowTimelineIfAvailable" type="bool">True</property>
              <property name="Width" type="string" />
              <property name="DataFields" type="string" />
              <property name="Hidden" type="bool">False</property>
              <property name="Title" type="string" />
              <property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
              <property name="DataSourcesString" type="string" />
              <property name="AllowClose" type="bool">True</property>
              <property name="InplaceSearchEnabled" type="bool">True</property>
              <property name="WebId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
              <property name="Height" type="string" />
              <property name="GhostedXslLink" type="string">main.xsl</property>
              <property name="DisableViewSelectorMenu" type="bool">False</property>
              <property name="DisplayName" type="string" />
              <property name="IsClientRender" type="bool">False</property>
              <property name="InitialAsyncDataFetch" type="bool">False</property>
              <property name="AllowHide" type="bool">True</property>
              <property name="ParameterBindings" type="string">&lt;ParameterBinding Name="dvt_sortdir" Location="Postback;Connection" /&gt;&lt;ParameterBinding Name="dvt_sortfield" Location="Postback;Connection" /&gt;&lt;ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue="" /&gt;&lt;ParameterBinding Name="dvt_firstrow" Location="Postback;Connection" /&gt;&lt;ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" /&gt;&lt;ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" /&gt;&lt;ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" /&gt;&lt;ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" /&gt;&lt;ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noitemsinview_doclibrary)" /&gt;&lt;ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noitemsinview_doclibrary_howto2)" /&gt;</property>
              <property name="DataSourceMode" type="Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">List</property>
              <property name="AutoRefreshInterval" type="int">60</property>
              <property name="AsyncRefresh" type="bool">False</property>
              <property name="HelpUrl" type="string" />
              <property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
              <property name="XslLink" type="string" null="true" />
              <property name="SelectParameters" type="string" />
              <property name="HasClientDataSource" type="bool">False</property>
            </properties>
          </data>
        </webPart>
      </webParts>
    </pnp:Contents>
  </pnp:WebPart>

This works well, I can see the web part on the page. I have another list, called SecurityReports. I want this the same way presented on the page. So, I made a copy of this, changed some properties like

<pnp:WebPart Title="SecurityReports" Zone="Body" Order="2">
<property name="ListName" type="string">{{listid:SecurityReports}}</property>
              <property name="ListId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">{listid:SecurityReports}</property>

But when I apply the template, I don't see any new webpart added. I can see this in the logs: PowerShell_ISE.exe Information: 0 : 2018-08-07 11:35:05.8413 [Files] [17] [Debug] Adding webpart 'SecurityReports' to page 9505ms 08a5afc1-a738-4493-93d9-7d53a85efe8f

The web part is not hidden, I don't see anything in edit page mode. The list exists, I tested, when I enter an invalid list name I get an error message. I tried to copy the original Documents list view, just to see if adding a second web part works, that was ok. Tried to add the list id static, changing the order of the web parts in the file, only the original Documents webpart is added. I also deleted the target aspx file before every template apply. Tried manually adding the web part, exporting and adding it to the template. No success, the list view didn't appear. Any ideas welcome.

Update I removed the references to the listid and listname and filled the listurl property only. Now I get this:

Apply-PnPProvisioningTemplate : List View Web Part could not be added, list may be hidden.
2
  • On which type of page do you try to import this webpart? Is it a classic wikipage/webpartpage? – Johan Brännmar Aug 7 '18 at 10:50
  • This is a webpart page. – vilmarci Aug 7 '18 at 10:53
0

Well, I'm not sure if I should post this as answer. Now it works, but I don't really know why: I replaced this:

<property name="ListUrl" type="string" null="true" />

With this:

<property name="ListUrl" type="string">SecurityReports</property>

So, the key was not only adding the url and remove the other references, but remove the null="true" attribute too. Still, I don't really know why does it work with the Shared Documents library and why do I need to do this trick with this one. If anyone knows the why, I'll accept that answer :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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