copy list items from one list to another in sharepoint

前端 未结 11 2080
无人共我
无人共我 2020-12-14 20:35

In Sharepoint how can you copy a list item from one list to another list eg copy from \"List A\" to \"List B\" (both are at the root of the site)

I want this copying

11条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 20:56

    Here is a powershell equivalent of Sylvian's that does allow for cross-site copy. His code could be modified similarly as well...

    param([string]$sourceWebUrl, [string]$sourceListName, [string]$destWebUrl, [string]$destListName)
    
    $sourceWeb = get-spweb $sourceWebUrl;
    $sourceList = $sourceWeb.Lists[$sourceListName];
    $destWeb = get-spweb $destWebUrl;
    $destList = $destWeb.Lists[$destListName];
    $sourceList.Items |%{
    $destItem = $destList.Items.Add();
    $sourceItem = $_;
    $sourceItem.Fields |%{
        $f = $_;
        if($f.ReadOnlyField -eq $false -and $f.InternalName -ne "Attachments" -and $sourceItem[$f.InternalName] -ne $null){
            $destItem[$f.InternalName] = $sourceItem[$f.InternalName];
        }
    }
    $destItem.Update();
    }
    

    To use, copy and past to a file copy-listitems.ps1 and run using Sharpoint powerhsell commandline...

提交回复
热议问题