将Person项从List A复制到List B. [英] Copy a Person item from List A to List B
问题描述
我的Powershell脚本是:
                
$ snapin = Get-PSSnapin | Where-Object {$ _。Name -eq'Microsoft.SharePoint.Powershell'}
if($ snapin -eq $ null){Add-PSSnapin Microsoft.SharePoint.Powershell}
$
$ web = Get-SPWeb http:// intranet / Operations / RestrictedArea
$ listTODO = $ web.Lists [" ToDo"]
$
$ Fund = get-spweb http:// intranet / sites / clients
$ listFunds = $ Fund.Lists [" Client"]
$ allFunds = $ listFunds.GetItems($ listFunds.Views [" All Clients"]] )b $ list $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ today =获取日期
foreach($ itemTODO in $ listTODO.Items | Where { $ _ [" Frequency"] -eq" Daily"})
{
  ##指定基金时为
  if($ itemTODO [" Fund"] -ne $ null){
$
    $ commonValue = $ itemTODO [" Fund"] .Tostring()。Split(" |")[0]
$
    $ itemsFunds = $ allFunds | Where-Object {$ _ [" Fund"] .Tostring()。Split(",")[1] .ToString()。Trim()-eq $ commonValue}
    $ newItem = $ listTarget.Items.Add();
    $ newItem [" Fund Name"] = $ commonValue
    $ newItem [" Task Name"] = $ itemTODO [" Fund"]。Label +" - > " + $ itemTODO [" Title"]
    $ newItem [" Link"] = $ itemTODO [" Link"]
    $ newItem [" Link 2"] = $ itemTODO [" Link 2"]
    $ newItem [" Details"] = $ itemTODO [" Details"]
    $ newItem [" Category"] = $ itemTODO [" Category"]
    $ newItem [" StartDate"] = $ today.ToShortDateString()
    $ newItem [" DueDate"] = $ today.ToShortDateString()
    $ newItem.Update()
  }
}
我的问题是我有人物选择器列"关注"有多个选择。我想在目标列表中复制此项目时,每个被选中的人都会在不同的行中获得自己的任务。
您好,
我建议复制多用户字段值 而不是复制重复列表项数据 到目标列表然后按[Me]
过滤所以当前用户可以看到自己的任务。
用于复制多个用户字段值的示例脚本。
if((Get-PSSnapin" Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue)-eq
< blockquote> null){
Add-PSSnapin" Microsoft.SharePoint.PowerShell"
}
#Script设置
webUrl =" http:// sp"
My Powershell Script is :
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null) { Add-PSSnapin Microsoft.SharePoint.Powershell }
$web = Get-SPWeb http://intranet/Operations/RestrictedArea
$listTODO = $web.Lists["ToDo"]
$Fund = get-spweb http://intranet/sites/clients
$listFunds = $Fund.Lists["Client"]
$allFunds = $listFunds.GetItems($listFunds.Views["All Clients"])
$listTarget = $web.Lists["CheckList"]
$listTarget.Title
$today = Get-Date
foreach($itemTODO in $listTODO.Items | Where {$_["Frequency"] -eq "Daily"})
{
##When a fund is specified
if ($itemTODO["Fund"] -ne $null) {
$commonValue = $itemTODO["Fund"].Tostring().Split("|")[0]
$itemsFunds = $allFunds | Where-Object { $_["Fund"].Tostring().Split(",")[1].ToString().Trim() -eq $commonValue}
$newItem = $listTarget.Items.Add();
$newItem["Fund Name"] = $commonValue
$newItem["Task Name"] = $itemTODO["Fund"].Label + " -> " + $itemTODO["Title"]
$newItem["Link"] = $itemTODO["Link"]
$newItem["Link 2"] = $itemTODO["Link 2"]
$newItem["Details"] = $itemTODO["Details"]
$newItem["Category"]= $itemTODO["Category"]
$newItem["StartDate"] = $today.ToShortDateString()
$newItem["DueDate"] = $today.ToShortDateString()
$newItem.Update()
}
}
My Problem that i have a People Picker Column "Concerned" with Multiple selection. I want when copying this item in the Target list, every person selected get his own task in different row.
Hi,
I would suggest copy the muti user field value instead of copy duplicate listitems data to target list and then filter by [Me] so current user can see their own tasks.
Sample script to copy muti user field values.
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq
null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } #Script settings
webUrl = "http://sp"
这篇关于将Person项从List A复制到List B.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!