【问题标题】:Copy column of list to new column of same list in Sharepoint将列表列复制到 Sharepoint 中同一列表的新列
【发布时间】:2020-10-09 08:31:47
【问题描述】:

我想将整个列值复制到一个新列。 作为解决方案,我准备了一个工作流程:

SET FIELD TO VALUE and make the workflow start when item update

但是,我有 16000 多行,目前无法手动更新每一行。 我也尝试过使用 Microsoft Flow,但没有成功。

谁能提出一个实现它的方法。

【问题讨论】:

  • 感谢您的建议,但我在 VIEW 下使用 QUICK EDIT 进行了更新。一次将视图更改为 2000 行,并更新了 8 次所有行。花了大约 15 分钟,但一次更新,没关系。 :)

标签: sharepoint-2013 sharepoint-designer


【解决方案1】:

我建议使用 PowerShell 进行此类“迁移”工作。来自here的脚本,该脚本需要在SharePoint服务器中运行。

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Parameters
$SiteURL = "http://siteurl/"
$listName = "list"

$web = Get-SPweb $SiteURL

#Use the Display Names
$CopyFromColumnName = "Description" #column copy source
$CopyToColumnName = "Desc"  #destination column

#Get the List
$list = $web.lists[$ListName]

#Get all Items 
$Items = $list.Items

ForEach ($Item in $items)
{
   #copy data from one column to another
   $item[$copyToColumnName] = $item[$copyFromColumnName]

   #Do a system update to avoid Version and to Keep same metadata
   $item.SystemUpdate($false)
}

SharePoint online,请参考this thread,将迭代逻辑替换为分页。

$Query = New-Object Microsoft.SharePoint.Client.CamlQuery
    $Query.ViewXml = "<View Scope='RecursiveAll'><Query><OrderBy><FieldRef Name='ID' Ascending='TRUE'/></OrderBy></Query><RowLimit Paged='TRUE'>$BatchSize</RowLimit></View>"

    $Counter = 0
    #Batch process list items - to mitigate list threshold issue on larger lists
    Do { 
        #Get items from the list
        $ListItems = $List.GetItems($Query)
        $Ctx.Load($ListItems)
        $Ctx.ExecuteQuery()

        $Query.ListItemCollectionPosition = $ListItems.ListItemCollectionPosition

        #Loop through each List item
        ForEach($ListItem in $ListItems)
        {
            //to do copy field value
            $Counter++
            Write-Progress -PercentComplete ($Counter / ($List.ItemCount) * 100) -Activity "Processing Items $Counter of $($List.ItemCount)" -Status "Searching Unique Permissions in List Items of '$($List.Title)'"
        }
    } While ($Query.ListItemCollectionPosition -ne $null)

【讨论】:

  • 感谢您的建议,但我在 VIEW 下使用 QUICK EDIT 进行了更新。一次将视图更改为 2000 行,并更新了 8 次所有行。花了大约 15 分钟,但一次更新,没关系。 :)
猜你喜欢
  • 1970-01-01
  • 2010-10-29
  • 2013-04-27
  • 1970-01-01
  • 1970-01-01
  • 2012-11-25
  • 2012-02-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多