Forum Discussion
Duplicate and update SharePoint list dynamically
- Sep 09, 2022
In order to create replica of the list (Without data), you can use OOTB option shown in below screen shot:
In order to copy existing data from source to destination list you can use below PowerShell script to do so which uses PnP.PowerShell
You still need to update field names in below script according to your list.$sourceWebUrl = "https://contoso.sharepoint.com/sites/SourceSite" $destinationWebUrl = "https://contoso.sharepoint.com/sites/DestinationSite" #Connect to source site Connect-PnPOnline -Url $sourceWebUrl -Interactive $listName = "AssetTypeMaster" $fields = "AssetType", "Description", "AseetTypeDescription" #Retrieves items $listItems = Get-PnPListItem -List $listName -Fields $fields #Write lists item to other list #Connect to destination site Connect-PnPOnline -Url $destinationWebUrl -Interactive foreach($listItem in $listItems) { $itemValues = @{ "AssetType" = $listItem["AssetType"]; "Description" = $listItem["Description"]; "AseetTypeDescription" = $listItem["AseetTypeDescription"] } Add-PnPListItem -List $listName -Values $itemValues }For syncing of the data between these two lists, there is not OOTB way but you could use Power Automate to do so. Following is the reference link to do so.
- https://sharepains.com/2021/12/17/synchronize-two-data-sources-power-automate/
- https://tomriha.com/how-to-synchronise-two-sharepoint-lists-with-power-automate/
Hope it will helpful to you and if so then Please mark my response as Best Response & Like to help others in this community
In order to create replica of the list (Without data), you can use OOTB option shown in below screen shot:
In order to copy existing data from source to destination list you can use below PowerShell script to do so which uses PnP.PowerShell
You still need to update field names in below script according to your list.
$sourceWebUrl = "https://contoso.sharepoint.com/sites/SourceSite"
$destinationWebUrl = "https://contoso.sharepoint.com/sites/DestinationSite"
#Connect to source site
Connect-PnPOnline -Url $sourceWebUrl -Interactive
$listName = "AssetTypeMaster"
$fields = "AssetType", "Description", "AseetTypeDescription"
#Retrieves items
$listItems = Get-PnPListItem -List $listName -Fields $fields
#Write lists item to other list
#Connect to destination site
Connect-PnPOnline -Url $destinationWebUrl -Interactive
foreach($listItem in $listItems) {
$itemValues = @{
"AssetType" = $listItem["AssetType"];
"Description" = $listItem["Description"];
"AseetTypeDescription" = $listItem["AseetTypeDescription"]
}
Add-PnPListItem -List $listName -Values $itemValues
}
For syncing of the data between these two lists, there is not OOTB way but you could use Power Automate to do so. Following is the reference link to do so.
- https://sharepains.com/2021/12/17/synchronize-two-data-sources-power-automate/
- https://tomriha.com/how-to-synchronise-two-sharepoint-lists-with-power-automate/
Hope it will helpful to you and if so then Please mark my response as Best Response & Like to help others in this community