pnp / PnP-Sites-Core

Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Other
415 stars 644 forks source link

[BUG] Get-PnPProvisioningTemplate fails once it gets to the built-in "Documtents" List instance #2735

Closed Theohorsmeier closed 4 years ago

Theohorsmeier commented 4 years ago

Environment

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

SharePointPnPPowerShellOnline 3.24.2008.0

Expected or Desired Behavior

Expected behaviour is to have the PnP template get exported

Observed Behavior

I get the following WriteError: Get-PnPProvisioningTemplate : At line:1 char:3

The Exception: CorrelationId : ad42719f-10f3-2000-b504-eaf537fbe43d TimeStampUtc : 8/18/2020 2:34:25 PM Message : Stacktrace : at OfficeDevPnP.Core.Utilities.WebhookUtility.<GetWebhooksSubscriptionsAsync>d__10.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.ListExtensions.<GetWebhookSubscriptionsAsync>d__16.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 OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectListInstance.ExtractWebhooks(List siteList, ListInstance list) at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectListInstance.ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo) at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.GetRemoteTemp late(Web web, ProvisioningTemplateCreationInformation creationInfo) at PnP.PowerShell.Commands.Provisioning.Site.GetProvisioningTemplate.ExtractTemplate(XMLPnPSchema Version schema, String path, String packageName, ExtractConfiguration configuration) at PnP.PowerShell.Commands.Provisioning.Site.GetProvisioningTemplate.ExecuteCmdlet() at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() ScriptLineNumber : 1

Steps to Reproduce

Happens with a newly made sitecollection or any subsite.

In SharePointPnPPowerShellOnline 3.24.2008.0,

It fails when it is doing the List instances, specifically the list "Documtents". Get-PnPProvisioningTemplate Fails Get-PnPProvisioningTemplate -ListsToExtract "Shared Documents" works, Get-PnPProvisioningTemplate -ListsToExtract "Documents" Fails

In SharePointPnPPowerShellOnline 3.23.2007.1 , everything seems fine.

ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

sympmarc commented 4 years ago

This is actually the correct line:

Get-PnPProvisioningTemplate -ListsToExtract "Shared Documents"

I'd recommend using a PnP Extraction Configuration file for your setup. It gives you some nice repeatability. It also allows you to target exactly which artifacts in the site you want.

Here's a slightly redacted example I'm using in one of my projects:


{
    "$schema":"https://aka.ms/sppnp-extract-configuration-schema",
    "handlers": [
        "WebSettings",
        "Navigation",
        "Fields",
        "ContentTypes",
        "Lists",
        "Pages"
    ],
    "navigation": {
        "removeExistingNodes": true
    },
    "contentTypes": {
        "groups": [
            "_ClientName",
            "_ClientName Accounting",
            "_ClientName Organizational",
            "_ClientName Property Operations",
            "_ClientName Tenants"
        ]
    },
    "lists": {
        "lists": [
            {
                "title": "Property Operations"
            },
            {
                "title": "Tenants"
            },
            {
                "title": "Accounting & Finance"
            },
            {
                "title": "Organizational & Loan Documents"
            },
            {
                "title": "Acquisition & Development"
            },
            {
                "title": "Archive"
            }
        ]
    }
}
'''
Theohorsmeier commented 4 years ago

Hi @sympmarc , thanks for your suggestion, it looks like that gives a lot of control over what to export!

I guess choosing exactly what to export, and thus making sure "Shared Documents" is exported using the correct name, will circumvent this problem.

It does mean that for every export I need to compile this configuration, which I was trying to avoid by "just exporting the whole site" at once, almost all the templates I will be exporting will have a different set of lists for example.

Do you use another script to compile this configuration for a specific existing site?

sympmarc commented 4 years ago

You can use the same configuration file for multiple exports, of course.

When I run Get-PnPProvisioningTemplate -Out temp.xml with no parameters (other than -Out), I get a full site export with no errors.

I'm on SharePointPnPPowerShellOnline 3.24.2008 as well.

In the site where I tested, the Documents (Shared Documents) library is unchanged from the defaults:

<pnp:ListInstance Title="Documents" Description="" DocumentTemplate="{site}/Shared Documents/Forms/template.dotx" TemplateType="101" Url="Shared Documents" EnableVersioning="true" MinorVersionLimit="0" MaxVersionLimit="500" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-e717-4e80-aa17-d0c71b360101" EnableAttachments="false" ListExperience="NewExperience" DefaultDisplayFormUrl="{site}/Shared Documents/Forms/DispForm.aspx" DefaultEditFormUrl="{site}/Shared Documents/Forms/EditForm.aspx" DefaultNewFormUrl="{site}/Shared Documents/Forms/Upload.aspx" ImageUrl="/_layouts/15/images/itdl.png?rev=47" IrmExpire="false" IrmReject="false" IsApplicationList="false" ValidationFormula="" ValidationMessage="">
    <pnp:ContentTypeBindings>
        <pnp:ContentTypeBinding ContentTypeID="0x0101" Default="true" />
        <pnp:ContentTypeBinding ContentTypeID="0x0120" />
    </pnp:ContentTypeBindings>
    <pnp:Views>
        <View Name="{3AF5AF68-E7E7-43C5-8BB4-DDB853B1FB87}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All Documents" Url="{site}/Shared Documents/Forms/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/dlicon.png?rev=47">
            <Query>
                <OrderBy>
                    <FieldRef Name="FileLeafRef" />
                </OrderBy>
            </Query>
            <ViewFields>
                <FieldRef Name="DocIcon" />
                <FieldRef Name="LinkFilename" />
                <FieldRef Name="Modified" />
                <FieldRef Name="Editor" />
            </ViewFields>
            <RowLimit Paged="TRUE">30</RowLimit>
            <JSLink>clienttemplates.js</JSLink>
        </View>
    </pnp:Views>
    <pnp:FieldRefs>
        <pnp:FieldRef ID="d307dff3-340f-44a2-9f4b-fbfe1ba07459" Name="_CommentCount" DisplayName="Comment count" />
        <pnp:FieldRef ID="db8d9d6d-dc9a-4fbd-85f3-4a753bfdc58c" Name="_LikeCount" DisplayName="Like count" />
    </pnp:FieldRefs>
</pnp:ListInstance>
Theohorsmeier commented 4 years ago

@sympmarc Yeah this is also what I am used to getting, a normal export. I found out that on another machine, where I am on an earlier version of PnP, every export is working fine... SharePointPnPPowerShellOnline 3.23.2007.1 for example seems to have no problem.

Thanks again for your response!

Oh I see you are also on the new version.

sympmarc commented 4 years ago

I'm on SharePointPnPPowerShellOnline 3.24.2008 as well.

Theohorsmeier commented 4 years ago

Ok I have one machine where it works, and two where it fails, but considering you are on the new version as well, it probably is something else.

The one I used while writing the bug report has been my main PnP machine for a while though, so I don't understand what could be the problem...

But thanks @sympmarc for confirming the version is probably not the problem and I need to look somewhere else (or continue on the machine where it is fine :P)

sympmarc commented 4 years ago

If you don't think it's an issue with the cmdlet, can you close the issue? And no problem!

get-mrsmit commented 3 years ago

i have this problem also on a tenant. Does not matter what i do if i try te generate a template it wont work.

Could it has to do something with the new pnp core powershell? i saw that the cmdlets in that module is different