Share via


TermSetItem.CreateTerm method (String, Int32, Guid)

Creates a new Term object below this TaxonomyItem object.The name is the default Label for the specified LCID.

Namespace:  Microsoft.SharePoint.Taxonomy
Assembly:  Microsoft.SharePoint.Taxonomy (in Microsoft.SharePoint.Taxonomy.dll)

Syntax

'Declaration
Public Function CreateTerm ( _
    name As String, _
    lcid As Integer, _
    newTermId As Guid _
) As Term
'Usage
Dim instance As TermSetItem
Dim name As String
Dim lcid As Integer
Dim newTermId As Guid
Dim returnValue As Term

returnValue = instance.CreateTerm(name, _
    lcid, newTermId)
public Term CreateTerm(
    string name,
    int lcid,
    Guid newTermId
)

Parameters

Return value

Type: Microsoft.SharePoint.Taxonomy.Term
The newly created Term object

Exceptions

Exception Condition
UnauthorizedAccessException

The current user has insufficient permissions to perform this operation.

TermStoreOperationException

This operation is invalid in the Orphaned Terms term set.The operation failed.

TermStoreOperationException

Keyword term set only allows a flat list of Terms.

ArgumentException

The name is not valid, it contains invalid characters, or is too long.

ArgumentNullException

The name is a null reference (Nothing in Visual Basic) or empty string.

ArgumentOutOfRangeException

The lcid is not valid.

Remarks

If the specified LCID is not the default language of the TermStore, a Label with the name and the default language of the TermStore will also be created to ensure the Term has a default Label for the default language of the TermStore.

If the current TermSetItem is the Keyword Term Set, then label is always created for the term store default language.

The name value will be normailized to trim consecutive spaces into one and replace the & character with the wide character version of the character (\uFF06). The leading and trailing spaces will be trimmed. It must be non-empty and cannot exceed 255 characters, and cannot contain any of the following characters ;"<>|&tab

The current user will be set as the owner of the new Term.

If the newTermId already exists in the TermStore, an exception will be thrown.

If the TermSet for this TaxonomyItem is not an open TermSet then the current user must have TaxonomyRights.EditTerm permission to use this method. CommitAll() must be called to save this change to the database.

See also

Reference

TermSetItem class

TermSetItem members

CreateTerm overload

Microsoft.SharePoint.Taxonomy namespace