Skip to main content

QueryResult

Last updated 1/10/2024

QueryResult Object

The

QueryResult
object is an object returned from
executeQuery()
which contains information about the results returned from the query.
QueryResult
is inherited from
FiveError
, therefore you can use
isOk()
to know if the result was successful or not.

Functions

recordCount()

The

recordCount()
is a function used on the
QueryResult
object that tells how many records have been returned.

Function Signature
recordCount() : number;

Example

The code checks if we get a single record returned, otherwise returns an error indicating the request is invalid.

JavaScript
Checks if we get a single record returned
    let queryResults = five.executeQuery('SELECT SubmissionKey, ContactEmails FROM Submission WHERE SubmissionKey = ? AND Status = "NR"', 0, submissionKey);
if (queryResults.recordCount() !== 1) {
return five.success(result, 'Request is invalid');
}

Properties

records

The

records
property available on the
QueryResult
object contains the records that were returned from the data source.

Example

The following code selects five employee records from the Employee table and displays them in the Five Inspector.

JavaScript
executeQuery() using the optional limit parameter
let queryResult = five.executeQuery('SELECT Name from Employee', 5);
for (let i = 0; i < queryResult.recordCount(); i++) {
five.log('Employee : ' + queryResult.records[i].Name);
}