Forum Discussion

SuperUser19's avatar
SuperUser19
Copper Contributor
Sep 09, 2022
Solved

Duplicate and update SharePoint list dynamically

Hello Experts,   I would like to get my SharePoint list duplicated(with content) and whenever there is a change or new record in the original list the duplicated list should get dynamically updated...
  • kalpeshvaghela's avatar
    Sep 09, 2022

    SuperUser19 

     

    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.

     


    Hope it will helpful to you and if so then Please mark my response as Best Response & Like to help others in this community

     

Resources