Sp-dev-docs: Creating items in PnP Provisioning in SP Online site templates does not work

Created on 26 Nov 2020  路  5Comments  路  Source: SharePoint/sp-dev-docs

Category

  • [x] Bug

Describe the bug

I am creating templates using the PnP provisioning but am noticing the items are not being created. I have this template.json file

{
    "$schema":"https://aka.ms/sppnp-extract-configuration-schema",
    "persistAssetFiles": false,
    "handlers": [
        "Lists",
        "WebSettings",
        "Pages"
    ],
    "lists": {
        "lists": [
            {
                "title": "MyData",
                "includeItems": true
            }
        ]
    },
    "pages": {
        "includeAllClientSidePages": true
    }
}

and the exported XML file has the datarows data in it, but when I apply it to a site, the lists that get created don't have the data in it. Does anyone know what's wrong?

Steps to reproduce

  1. Create a site and a list MyData in it with some data
  2. Save it using Get-PnPProvisioningTemplate -Configuration "template.json" -Out "template.xml" -Force
  3. Create new site and apply template to it using Apply-PnPProvisioningTemplate -Path "template.xml"

Expected behavior

Items to be created in the provisioned lists

Environment details (development & target environment)

Windows 10
SharePoint Online
Node v10
Chrome 87
VS Code | SPFx v1.11.0

other answered question

All 5 comments

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

This question should be posted to the PnP provisioning repo's issue list as it's specific to provisioning, not general SP dev which is what this issue list is for. You're likely to get a better chance at a response there.

@TheInvoker,

Just tested your JSON and PowerShell cmdlets in my environment. Yeah, it did export the data rows but not create any item in the target site.

However, if I delete all system fields and only keep 'Title' field in <pnp:DataRow>, it works fine, the item will be created.

<pnp:DataRows UpdateBehavior="Overwrite"> <pnp:DataRow> <pnp:DataValue FieldName="Title">jytjtyjo</pnp:DataValue> </pnp:DataRow> </pnp:DataRows>

So I suspect that some fields (especially the built-in fields) can not be imported, which will cause the item creation gets failed.

Hence I suggest you only keep the expected fields. Or you can use Add-PnPDataRowsToProvisioningTemplate to help to add data rows.

Baker Kong
Microsoft SharePoint Community Support

This works, but a shorter version of choosing the fields to extract for items is this. This way all the related info is in one place.

        {
            "title": "Banner",
            "includeItems": true,
            "query": {
                "viewFields": ["Title"]
            }
        },

Closing this issue as "answered". If you encounter a similar issue(s), please open up a new issue. See our wiki for more details: Issue-List: Our approach to closed issues

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StfBauer picture StfBauer  路  3Comments

bengtmoss picture bengtmoss  路  3Comments

StfBauer picture StfBauer  路  3Comments

byrongits picture byrongits  路  3Comments

karishmaTCS picture karishmaTCS  路  3Comments