TermStore.GetTermsWithCustomProperty method (String, String, StringMatchOption, Boolean)

Gets a collection of all Term objects, from all TermSet objects in this TermStore that the current user has permissions to read, that have a custom property starting with or matching the provided property name and the provided property value.

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

public TermCollection GetTermsWithCustomProperty(
	string customPropertyName,
	string customPropertyValue,
	StringMatchOption stringMatchOption,
	bool trimUnavailable
)

Parameters

customPropertyName
Type: System.String

The custom property name

customPropertyValue
Type: System.String

The custom property value

stringMatchOption
Type: Microsoft.SharePoint.Taxonomy.StringMatchOption

Indicates whether to search for custom property names and values that start with the specified strings, or search for those that exactly match the specified strings.

trimUnavailable
Type: System.Boolean

A Boolean indicating whether to trim out terms that have Term.IsAvailableForTagging set to false.

Return value

Type: Microsoft.SharePoint.Taxonomy.TermCollection
A collection of all Term objects, from all TermSets in this TermStore that the current user has permissions to read, that have a custom property starting with or matching the provided property name and the provided property value.

ExceptionCondition
ArgumentNullException

The customPropertyName cannot be null or empty.

ArgumentException

The value of customPropertyName is invalid. It probably contains invalid characters or is too long.

ArgumentNullException

The customPropertyValue cannot be null or empty.

ArgumentException

The value of customPropertyValue is invalid. It exceeds the maximum allowed length 255.

ArgumentException

The value of customPropertyValue is invalid. It contains invalid character '\t', '\n'. or both.

If trimUnavailable is true then terms that have Term.IsAvailableForTagging set to false will be trimmed from the results; otherwise all matching terms will be returned regardless of their Term.IsAvailableForTagging value.

The customPropertyName cannot be a null reference (Nothing in Visual Basic) or empty, and must not exceed 255 characters in length. It also cannot contain any of the following illegal characters ;"<>|&tab

The customPropertyValue cannot be a null reference (Nothing in Visual Basic) or empty, and must not exceed 255 characters in length. It also cannot contain any of the illegal characters \t or \n.

The search is case-insensitive. A maximum of 100 results will be returned from this search. To get the most accurate results it is recommended that any pending changes be committed to the database using CommitAll() before executing this search.

Show: