Sep 12 2023 11:53 AM
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?
Sep 12 2023 11:21 PM
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>
Documentation: Configuring 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.
Sep 13 2023 01:07 AM
@ganeshsanap
Yes, I see DataRows like this
<pnp:DataRows UpdateBehavior="Overwrite">
<pnp:DataRow />
<pnp:DataRow />
</pnp:DataRows>
Sep 13 2023 01:15 AM
@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.
Sep 14 2023 01:13 AM - edited Sep 14 2023 01:16 AM
@ganeshsanap
There was not any error/warning while invoking and after execution.
I tried to do the same on another List.
I created a new List "SimpleList" and followed the same steps.
Now it seems that the items have been transferred, but with empty values in the fields.
There were no any error/warning while invoking and after execution either.
By the way, I use Team Site. Maybe this can only be done on Communication Site?
Sep 14 2023 01:35 AM - edited Sep 14 2023 01:36 AM
SolutionHi @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
Sep 14 2023 03:35 AM
@SvenSieverding Thank you very much for your response!
Sep 14 2023 01:35 AM - edited Sep 14 2023 01:36 AM
SolutionHi @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