AFElement.FindElements Method (AFDatabase, AFElement, String, String, AFCategory, AFElementTemplate, AFElementType, Boolean, AFSortField, AFSortOrder, Int32, Int32, Int32)
- Last UpdatedNov 18, 2025
- 7 minute read
- PI System
- AF SDK 2024 R2
- Developer
Note: This API is now obsolete.
Namespace: OSIsoft.AF.Asset
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
[BrowsableAttribute(false)] [ObsoleteAttribute("This method has been replaced by the 'AFElementSearch' class using the 'Root', 'Name', 'Description', 'Category', 'Template', and 'Type' filters.")] public static AFNamedCollectionList<AFElement> FindElements( AFDatabase database, AFElement searchRoot, string nameFilter, string descriptionFilter, AFCategory elemCategory, AFElementTemplate elemTemplate, AFElementType elemType, bool searchFullHierarchy, AFSortField sortField, AFSortOrder sortOrder, int startIndex, int maxCount, out int totalCount )
<BrowsableAttribute(false)> <ObsoleteAttribute("This method has been replaced by the 'AFElementSearch' class using the 'Root', 'Name', 'Description', 'Category', 'Template', and 'Type' filters.")> Public Shared Function FindElements ( database As AFDatabase, searchRoot As AFElement, nameFilter As String, descriptionFilter As String, elemCategory As AFCategory, elemTemplate As AFElementTemplate, elemType As AFElementType, searchFullHierarchy As Boolean, sortField As AFSortField, sortOrder As AFSortOrder, startIndex As Integer, maxCount As Integer, <OutAttribute> ByRef totalCount As Integer ) As AFNamedCollectionList(Of AFElement) Dim database As AFDatabase Dim searchRoot As AFElement Dim nameFilter As String Dim descriptionFilter As String Dim elemCategory As AFCategory Dim elemTemplate As AFElementTemplate Dim elemType As AFElementType Dim searchFullHierarchy As Boolean Dim sortField As AFSortField Dim sortOrder As AFSortOrder Dim startIndex As Integer Dim maxCount As Integer Dim totalCount As Integer Dim returnValue As AFNamedCollectionList(Of AFElement) returnValue = AFElement.FindElements(database, searchRoot, nameFilter, descriptionFilter, elemCategory, elemTemplate, elemType, searchFullHierarchy, sortField, sortOrder, startIndex, maxCount, totalCount)
public: [BrowsableAttribute(false)] [ObsoleteAttribute(L"This method has been replaced by the 'AFElementSearch' class using the 'Root', 'Name', 'Description', 'Category', 'Template', and 'Type' filters.")] static AFNamedCollectionList<AFElement^>^ FindElements( AFDatabase^ database, AFElement^ searchRoot, String^ nameFilter, String^ descriptionFilter, AFCategory^ elemCategory, AFElementTemplate^ elemTemplate, AFElementType elemType, bool searchFullHierarchy, AFSortField sortField, AFSortOrder sortOrder, int startIndex, int maxCount, [OutAttribute] int% totalCount )
[<BrowsableAttribute(false)>] [<ObsoleteAttribute("This method has been replaced by the 'AFElementSearch' class using the 'Root', 'Name', 'Description', 'Category', 'Template', and 'Type' filters.")>] static member FindElements : database : AFDatabase * searchRoot : AFElement * nameFilter : string * descriptionFilter : string * elemCategory : AFCategory * elemTemplate : AFElementTemplate * elemType : AFElementType * searchFullHierarchy : bool * sortField : AFSortField * sortOrder : AFSortOrder * startIndex : int * maxCount : int * totalCount : int byref -> AFNamedCollectionList<AFElement>
Parameters
- database
- Type: OSIsoft.AFAFDatabase
The AFDatabase to search for the requested objects. - searchRoot
- Type: OSIsoft.AF.AssetAFElement
The root object to start the search. If , then the search starts at the AFDatabase. - nameFilter
- Type: SystemString
The name filter string used for finding objects.The query string (or match pattern) can include regular characters and wildcard characters. Regular characters must match exactly the characters specified in the query string. Wildcard characters can be matched with arbitrary fragments of the query string. Wildcard characters can be escaped using the single backslash (\) character. Use a double backslash (\\) to match a single backslash. The syntax of the query string has the following rules:
- If or empty string, then everything will be matched.
- If no wildcards, then an exact match on the query string is performed.
- Wildcard * can be placed anywhere in the query string and matches zero or more characters.
- Wildcard ? can be placed anywhere in the query string and matches exactly one character.
- One character in a set of characters are matched by placing them within [ ]. For example, a[bc] would match 'ab' or 'ac', but it would not match 'ad' or 'abd'.
- One character in a set of characters are not matched by placing them within [! ]. For example, a[!bc] would match 'ad', but it would not match 'ab', 'ac', or 'abd'.
- A character in a range of characters from first to last are matched using the following syntax: [first - last]. For example, a[a-c] would match 'aa', 'ab', or 'ac', but it would not match 'ad' or 'abc'.
- descriptionFilter
- Type: SystemString
The element description filter string used for finding objects. Only the first 440 characters of the description will be searched. For servers older than 2.7, a NotSupportedException exception will be thrown if this parameter is specified.The query string (or match pattern) can include regular characters and wildcard characters. Regular characters must match exactly the characters specified in the query string. Wildcard characters can be matched with arbitrary fragments of the query string. Wildcard characters can be escaped using the single backslash (\) character. Use a double backslash (\\) to match a single backslash. The syntax of the query string has the following rules:
- If or empty string, then everything will be matched.
- If no wildcards, then an exact match on the query string is performed.
- Wildcard * can be placed anywhere in the query string and matches zero or more characters.
- Wildcard ? can be placed anywhere in the query string and matches exactly one character.
- One character in a set of characters are matched by placing them within [ ]. For example, a[bc] would match 'ab' or 'ac', but it would not match 'ad' or 'abd'.
- One character in a set of characters are not matched by placing them within [! ]. For example, a[!bc] would match 'ad', but it would not match 'ab', 'ac', or 'abd'.
- A character in a range of characters from first to last are matched using the following syntax: [first - last]. For example, a[a-c] would match 'aa', 'ab', or 'ac', but it would not match 'ad' or 'abc'.
- elemCategory
- Type: OSIsoft.AFAFCategory
Specify that the returned elements must have this category. To not filter by element category, then specify for this parameter. For servers older than 2.7, a NotSupportedException exception will be thrown if this parameter is specified. - elemTemplate
- Type: OSIsoft.AF.AssetAFElementTemplate
Specify that returned elements must have this template or a template derived from this template. To not filter by element template, then specify for this parameter. - elemType
- Type: OSIsoft.AF.AssetAFElementType
Specify that returned elements must have this Type. To not filter by element type, then specify AFElementType.Any for this parameter. - searchFullHierarchy
- Type: SystemBoolean
Specifies if the search should include objects nested further than the immediate children of the searchRoot. - sortField
- Type: OSIsoft.AFAFSortField
The field or property of the object used to sort the returned collection. This value should not be changed between calls when attempting to get the next page of items. - sortOrder
- Type: OSIsoft.AFAFSortOrder
The order that the returned collection is sorted. This value should not be changed between calls when attempting to get the next page of items. - startIndex
- Type: SystemInt32
The starting index (zero based) of the items to be returned. - maxCount
- Type: SystemInt32
The maximum number of objects to be returned per call (the page size). - totalCount
- Type: SystemInt32
The total number of objects that match the search criteria.
Return Value
Type: AFNamedCollectionListAFElementReturns a collection containing the specified page of AFElement objects which match the specified nameFilter string and filters.
Remarks
An object matches the search if the specified nameFilter is found in the object's Name property. The returned list can be filtered even more by specifying one or more of the following: element category, element template, element type.
| If a searchRoot is specified and the searchFullHierarchy parameter is , then any added or removed element references that have not been checked in will be ignored when searching the hierarchy. |
| Consider using the new AFElementSearch class for finding elements instead of using this method. |
Version Information
AFSDK
Supported in: 2.8.5, 2.8, 2.7.5, 2.7Obsolete (compiler warning) in 3.1.1
Obsolete (compiler warning) in 3.1.0
Obsolete (compiler warning) in 3.0.2
Obsolete (compiler warning) in 3.0.1
Obsolete (compiler warning) in 3.0.0
Obsolete (compiler warning) in 2.10.11
Obsolete (compiler warning) in 2.10.5
Obsolete (compiler warning) in 2.10.0
Obsolete (compiler warning) in 2.10
Obsolete (compiler warning) in 2.9.5
Obsolete (compiler warning) in 2.9