Forum Discussion

Pavel2235's avatar
Pavel2235
Brass Contributor
Sep 12, 2023

List items don't copy when I use PnP Provisioning Engine

Hi!
I've a PowerShell script to get template from TestSite2 and invoke this template on TestSite3. 
I use config.json to get only list "testlist" template from TestSite2.

{
  "$schema":"https://aka.ms/sppnp-extract-configuration-schema",
  "persistAssetFiles": true,
  "handlers": [
    "Lists"
  ],
  "lists": {
    "lists": [
      {
        "title": "testlist",
        "includeItems": true,
        "query": {
          "includeAttachments": true
        }
      }
    ]
  }
}

Get-PnPSiteTemplate

#Set Variables
$SiteURL = "https://xxxxx.sharepoint.com/sites/TestSite2"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

Get-PnPSiteTemplate -Configuration "config.json" -Out "template.xml"

Invoke-PnpSiteTemplate

#Set Variables
$SiteURL = "https://xxxxx.sharepoint.com/sites/TestSite3"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

Invoke-PnPSiteTemplate -Path "template.xml"

 
My testlist on TestSite2 have a couple of items, but after invoking template on TestSite3, there are no any items, although I installed "includeItems": true.

Could you tell me please, why the items didn't copied?

  • Hi Pavel2235 ,

    I recently had issues like that.
    It seems like this: If you export list elements using the config file, then ALL properties of all fields are exported as datavalues... in order to import these items I had to remove the datavalues for "ContentType" and other internal columns. Then  an import worked.

    Btw: If you export a site template like this

     

    Get-PnPSiteTemplate list.xml -Handlers Lists -ListsToExtract "MyList"
    Add-PnPDataRowsToSiteTemplate -Path .\list.xml -List "MyList"

     

    then you don't get datavalue elements for internal columns (But that does not work well for files and attachmetns)

    Best Regards,
    Sven

  • Pavel2235 

     

    When you get the PnP site template in template.xml file, can you open it and see if it contains DataRow elements?

    Example: 

     

    <pnp:DataRows KeyColumn="Title" UpdateBehavior="Overwrite">
       <pnp:DataRow>
       </pnp:DataRow>
    </pnp:DataRows>

     

    DocumentationConfiguring the PnP Provisioning Engine  


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

    • Pavel2235's avatar
      Pavel2235
      Brass Contributor

      ganeshsanap 
      Yes, I see DataRows like this

      <pnp:DataRows UpdateBehavior="Overwrite">
          <pnp:DataRow />
          <pnp:DataRow />
      </pnp:DataRows>

       

      • ganeshsanap's avatar
        ganeshsanap
        MVP

        Pavel2235 oh ok. In that case the list items should have been created in new SharePoint list.

         

        Do you get any error/warning while invoking site template?


        Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources