In here Terms can be divided
into two types.
Managed terms:
created by users and often organized into a hierarchy.
Enterprise keywords: words or phrases that are added to SharePoint items. All
enterprise keywords are part of a single, non-hierarchical term set.
SharePoint Server 2013 includes
a predefined column named Enterprise Keywords. We can add this column to
content types or lists. When a user adds a value to the Enterprise Keywords
column, the enterprise keyword control is displayed. Enterprise keywords
control allows users to select enterprise keywords in addition to managed terms
and by default it allows for multiple values.
Enterprise Keywords
column can be added to a content type by using follow PowerShell function:
function AddTaxonomyFieldInContentTypes([string]$listname,
[string]$weburl){
$web=get-spweb $weburl
$targetlist=$web.lists[$listname]
if( $targetlist -ne $null){
$entField=$targetlist.Fields | where {$_.title -eq
"Enterprise Keywords"}
if($entField -ne $null){
$targetlist.Fields.Delete($entField);
}
$newField=$web.AvailableFields| where {$_.title -eq
"Enterprise Keywords"}
$targetlist.ContentTypes
| foreach {
if($_.name -ne "Folder"){
$_.FieldLinks.Add($newField); $_.Update()
}
}
$targetlist.Update();
} else {
write-host "$listname list is
empty"
}
}
Enterprise Keywords
column can be added to a list by using follow PowerShell function:
function AddTaxonomyFieldInLists([string]$listname,
[string]$weburl){
$web=get-spweb $weburl
$targetlist=$web.lists[$listname]
if( $targetlist -ne $null){
$entField=$targetlist.Fields | where {$_.title -eq
"Enterprise Keywords"}
if($entField -ne $null){
$targetlist.Fields.Delete($entField);
}
$newField=$web.AvailableFields| where {$_.title -eq
"Enterprise Keywords"}
$targetlist.Fields.Add($newField);
$targetlist.Update();
try{
$view = $targetlist.DefaultView
if(!$view.ViewFields.ToStringCollection().Contains($newField))
{
$view.ViewFields.add($newField)
$view.Update()
}
write-host
"$listname list and view Updated"
} catch {
write-host
"$listname Failed to Update View field."
}
} else {
write-host "$listname list is empty"
}
}
More
information about SharePoint 2013 managed metadata including terms, term sets, and enterprise keywords can be found here in MSDN.
No comments:
Post a Comment