Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFSearch.FindObjectFields Method (String, Int32, Int32)

AFSearch.FindObjectFields Method (String, Int32, Int32)

  • Last UpdatedNov 18, 2025
  • 7 minute read
AFSearch.FindObjectFields Method (String, Int32, Int32)
This method will return the values as an IList for the specified fields for each of the objects that match the search tokens.

Namespace:  OSIsoft.AF.Search
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public abstract IEnumerable<IList<Object>> FindObjectFields(
	string fields,
	int startIndex = 0,
	int pageSize = 0
)
Public MustOverride Function FindObjectFields ( 
	fields As String,
	Optional startIndex As Integer = 0,
	Optional pageSize As Integer = 0
) As IEnumerable(Of IList(Of Object))

Dim instance As AFSearch
Dim fields As String
Dim startIndex As Integer
Dim pageSize As Integer
Dim returnValue As IEnumerable(Of IList(Of Object))

returnValue = instance.FindObjectFields(fields, 
	startIndex, pageSize)
public:
virtual IEnumerable<IList<Object^>^>^ FindObjectFields(
	String^ fields, 
	int startIndex = 0, 
	int pageSize = 0
) abstract
abstract FindObjectFields : 
        fields : string * 
        ?startIndex : int * 
        ?pageSize : int 
(* Defaults:
        let _startIndex = defaultArg startIndex 0
        let _pageSize = defaultArg pageSize 0
*)
-> IEnumerable<IList<Object>> 

Parameters

fields
Type: SystemString
The string that defines the list of fields to be returned from the search for each object. The valid field names are listed below and are separated by whitespace. The order of the returned list of values for each object is defined by this parameter.
startIndex (Optional)
Type: SystemInt32
The starting index (zero based) of the items to be returned.
pageSize (Optional)
Type: SystemInt32
The page size used for retrieving objects from the server. If this parameter is less than or equal to zero, then the page size will be set to the current value of the CollectionPageSize setting.

Return Value

Type: IEnumerableIListObject
Returns an enumerable list of the values for the desired fields for each object found using the search tokens for this search object. The returned object fields for each object will be in the same order as defined by the fields parameter.

Exceptions

ExceptionCondition
FormatException This exception is thrown if the ThrowOnError property is and there is a format error in the search query.
NotSupportedException This exception is thrown if the ThrowOnError property is and one of the filters is not supported or the query is too complex to be evaluated by the server.
ArgumentNullException This exception is thrown if the fields parameter is a or empty string.

Remarks

This method can be used to return only the values for the specified fields for each of the objects that match the search tokens instead of returning the full object. This can improve performance when the full object is not required and only some of the object's fields will be used.

The following chart shows which object fields are supported by each AFSearch class.

The following is a list of the supported object field names along with a description of each field. Unless otherwise indicted, the field values are returned as strings.

NameDescription
Analysis The name of the found object's Analysis.
AnalysisID The ID of the found object's Analysis returned as a Guid.
Categories The list of the found object's Categories.
ConfigString The found object's ConfigString.
Contact The name of the found object's Contact.
ContactID The ID of the found object's Contact returned as a Guid.
CreationDate The date when the found object was created returned as an AFTime.
Description The found object's Description.
Destination The found object's Destination.
DestinationID The ID of the found object's Destination returned as a Guid.
DisplayDigits The found object's DisplayDigits returned as a Int32.
Duration The found object's Duration. This is the AFTimeSpan between the object's StartTime and EndTime.
Element The name of the found object's Element.
ElementID The ID of the found object's Element returned as a Guid.
EndTime The found object's EndTime returned as an AFTime.
ID The found object's ID returned as a Guid.
IsAcknowledged The value of the found object's IsAcknowledged setting returned as a Boolean.
IsAnnotated The value of the found object's IsAnnotated setting returned as a Boolean.
IsInternal The value of the found object's IsInternal returned as a Boolean.
IsManualDataEntry The value of the found object's IsManualDataEntry returned as a Boolean.
ModifyDate The date when the found object was last modified returned as an AFTime.
Name The found object's Name.
Parent The name of the found object's Parent.
PlugIn The name of the found object's PlugIn. For AFAnalysisSearch and AFAnalysisTemplateSearch it will be the name of either the AnalysisRulePlugIn or TimeRulePlugIn. For AFNotificationContactTemplateSearch, it will be the name of the DeliveryChannelPlugIn.
PlugInID The ID of the found object's PlugIn returned as a Guid. For AFAnalysisSearch and AFAnalysisTemplateSearch it will be the ID of either the AnalysisRulePlugIn or TimeRulePlugIn. For AFNotificationContactTemplateSearch, it will be the ID of the DeliveryChannelPlugIn.
ParentID The ID of the found object's Parent returned as a Guid.
SecurityString The found object's SecurityString.
SecurityToken The value of the found object's SecurityToken returned as an AFSecurityRightsToken.
Severity The found object's Severity.
Source The name of the found object's Source.
SourceID The ID of the found object's Source returned as a Guid.
StartTime The found object's StartTime returned as an AFTime.
Status The found object's Status.
Target The name of the found object's Target.
TargetID The ID of the found object's Target returned as a Guid.
Template The name of the found object's Template.
TemplateID The ID of the found object's Template returned as a Guid.
Trait The found object's Trait.
Type The found object's Type.
UOM The name of the found object's UOM.
UOMAbbr The found object's UOM Abbreviation.
UOMID The ID of the found object's UOM.
Value The value of the found object's AFAttribute returned as an AFValue. The returned value will not have its Attribute property set. For AFAttributeSearch this field is specified as 'Value'. Otherwise, this field is specified as a path to the attribute relative to owning Element (e.g. '|Attr#1' or '|Attr#1|Attr#2|Attr#3').

Examples

// Get the Database
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
if (myPISystem == null)
    throw new InvalidOperationException("Default PISystem was not found.");
AFDatabase myDB = myPISystem.Databases[dbName];
if (myDB == null)
    throw new InvalidOperationException("Database was not found.");

// Create a search to find all the event frames created from the 'Event'
// template and its 'Level' attribute value is less than 90.
int count;
using (var search = new AFEventFrameSearch(myDB, "FindEventFields", @"Template:'Event' |Level:<90.0"))
{
    search.CacheTimeout = TimeSpan.FromMinutes(10);

    // Do the search
    // Return specified fields as object list.
    count = 0;
    Console.WriteLine("Find Object Fields:");
    foreach (var row in search.FindObjectFields("ID Name StartTime EndTime |Level"))
    {
        count++;
        foreach (var item in row)
        {
            Console.Write("{0}, ", item);
        }
        Console.WriteLine();
    }
    Console.WriteLine("Found {0} EventFrames.", count);
}
' Get the Database
Dim myPISystems As New PISystems()
Dim myPISystem As PISystem = myPISystems.DefaultPISystem
If myPISystem Is Nothing Then
    Throw New InvalidOperationException("Default PISystem was not found.")
End If
Dim myDB As AFDatabase = myPISystem.Databases(dbName)
If myDB Is Nothing Then
    Throw New InvalidOperationException("Database was not found.")
End If

' Create a search to find all the event frames created from the 'Event'
' template and its 'Level' attribute value is less than 90.
Dim count As Integer
Using search As New AFEventFrameSearch(myDB, "FindEventFields", "Template:'Event' |Level:<90.0")

    search.CacheTimeout = TimeSpan.FromMinutes(10)

    ' Do the search

    ' Return specified fields as object list.
    count = 0
    Console.WriteLine("Find Object Fields:")
    For Each row As IList(Of Object) In search.FindObjectFields("ID Name StartTime EndTime |Level")
        count += 1
        For Each item As Object In row
            Console.Write("{0}, ", item)
        Next
        Console.WriteLine()
    Next
    Console.WriteLine("Found {0} EventFrames.", count)

End Using

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

Version Information

AFSDK

Supported in: 3.1.1, 3.1.0, 3.0.2, 3.0.1, 3.0.0, 2.10.11, 2.10.5, 2.10.0, 2.10, 2.9.5, 2.9

See Also

In This Topic
TitleResults for “How to create a CRG?”Also Available in