1

我正在通过执行将字段添加到现有列表中...

$spList.Fields.Add(
    "SourceManager",
    [Microsoft.SharePoint.SPFieldType]::User,
    $false
)

$spList.Fields["SourceManager"].Indexed = $true;
$spList.Fields["SourceManager"].EnforceUniqueValues = $true;
$spList.Fields["SourceManager"].Required = $true;
$spList.Fields["SourceManager"].Update();

这很好,但我也想将该字段设置为仅允许人员(而不是人员和组,因为这里的默认行为)。我找不到设置。

谁能指出我正确的方向?

4

1 回答 1

1

您将在更新之前设置字段的选择模式。这两个选项如下所示:

$spList.Fields.Add(
    "SourceManager",
    [Microsoft.SharePoint.SPFieldType]::User,
    $false
)

$spList.Fields["SourceManager"].Indexed = $true;
$spList.Fields["SourceManager"].EnforceUniqueValues = $true;
$spList.Fields["SourceManager"].Required = $true;

$spList.Fields["SourceManager"].SelectionMode = [Microsoft.SharePoint.SPFieldUserSelectionMode]::PeopleAndGroups; # For people and groups.
$spList.Fields["SourceManager"].SelectionMode = [Microsoft.SharePoint.SPFieldUserSelectionMode]::PeopleOnly; # For people only.


$spList.Fields["SourceManager"].Update();
于 2013-08-08T12:33:30.780 回答