AFElement.FindElementsByTemplate Method (AFDatabase, AFObject, AFElementTemplate, Boolean, AFSortField, AFSortOrder, Int32)
- Last UpdatedNov 18, 2025
- 4 minute read
- PI System
- AF SDK 2024 R2
- Developer
Retrieves a non-paged collection of AFElement objects that are instantiated from the specified
AFElementTemplate.
Namespace: OSIsoft.AF.Asset
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public static AFNamedCollectionList<AFElement> FindElementsByTemplate( AFDatabase database, AFObject searchRoot, AFElementTemplate template, bool includeDerived, AFSortField sortField, AFSortOrder sortOrder, int maxCount )
Public Shared Function FindElementsByTemplate ( database As AFDatabase, searchRoot As AFObject, template As AFElementTemplate, includeDerived As Boolean, sortField As AFSortField, sortOrder As AFSortOrder, maxCount As Integer ) As AFNamedCollectionList(Of AFElement) Dim database As AFDatabase Dim searchRoot As AFObject Dim template As AFElementTemplate Dim includeDerived As Boolean Dim sortField As AFSortField Dim sortOrder As AFSortOrder Dim maxCount As Integer Dim returnValue As AFNamedCollectionList(Of AFElement) returnValue = AFElement.FindElementsByTemplate(database, searchRoot, template, includeDerived, sortField, sortOrder, maxCount)
public: static AFNamedCollectionList<AFElement^>^ FindElementsByTemplate( AFDatabase^ database, AFObject^ searchRoot, AFElementTemplate^ template, bool includeDerived, AFSortField sortField, AFSortOrder sortOrder, int maxCount )
static member FindElementsByTemplate : database : AFDatabase * searchRoot : AFObject * template : AFElementTemplate * includeDerived : bool * sortField : AFSortField * sortOrder : AFSortOrder * maxCount : int -> AFNamedCollectionList<AFElement>
Parameters
- database
- Type: OSIsoft.AFAFDatabase
The AFDatabase to search for the requested objects. - searchRoot
- Type: OSIsoft.AFAFObject
The root object to start the search (either an AFDatabase, an AFElement, or an AFEventFrame). If specified, then only elements directly owned by the specified object will be returned. If , then all elements with the specified template are returned. - template
- Type: OSIsoft.AF.AssetAFElementTemplate
Specify that the returned elements must have this template or a template derived from this template if includeDerived is . If , then all elements without any template will be returned. - includeDerived
- Type: SystemBoolean
If , then all elements created from this template and any template that is derived from this template will be included in the returned collection. If , then only elements created from this template will be included. If template is , then this parameter is ignored. - sortField
- Type: OSIsoft.AFAFSortField
The field or property of the object used to sort the returned collection. - sortOrder
- Type: OSIsoft.AFAFSortOrder
The order that the returned collection is sorted. - maxCount
- Type: SystemInt32
The maximum number of objects to be returned.
Return Value
Type: AFNamedCollectionListAFElementReturns a collection containing the first page of AFElement objects that are instantiated from the specified AFElementTemplate.
Remarks
This method will return the elements that are instantiated from the specified AFElementTemplate. If a template is specified, then its QueryDate will be used to determine the collection of elements that are returned from this method. Otherwise, the QueryDate of the searchRoot or database will be used.
| Consider using the new AFElementSearch class for finding elements instead of using this method. |