zquery Method
Overview
This article describes the Order Builder zquery()
method. The zquery() method uses theZuora query()
method to execute a ZOQL query.
Syntax
List<zObject> zquery (String zoql)
Input Parameters
The zquery() method takes the following input parameter.
Parameter | Type | Description |
---|---|---|
zoql | String | The ZOQL query to be executed. See Query Statement Examples for more information. |
Response
The zquery() method returns a zApi.QueryResult
object that contains the query results in the records
field.
zApi.QueryResult
The QueryResult
object has the following properties.
Property | Type | Description |
---|---|---|
done | Boolean | Indicates whether the query is complete (true) or not (false). You can use this value as a loop condition while iterating through the results of your query. |
queryLocator | String | If done is false, this value can be passed to the zqueryMore() method to retrieve the next series of records. |
records | List | An array of zObjects of the appropriate type (Product, Account, Invoice, etc.), containing the requested data. |
size | Integer | The number of rows retrieved. If size is equal to zero, then no rows were retrieved. |
Exceptions
The zquery() method uses the following exception classes to catch the exception when an error occurs in the call:
zAPIException
zForceException
zRemoteException
Sample Code
// zApiInstance should be instantiated and the login() method must // have been invoked prior to invoking any other method on the // object try { String zoql = 'SELECT Id, Name from Account Where ID =\'4028e69926e9852f0126ead18246043f\''; List<Zuora.zObject> zobjs = zApiInstance.zquery(zoql); for (Zuora.zObject o : zobjs) { String aname = (String)o.getValue('Name'); //more code here... } } catch (Zuora.zRemoteException ex) { if ('INVALID_FIELD' == ex.code) { // An invalid field was specified //more code here... } else { //more code here... } } catch (Zuora.zAPIException ex) { ex.getMessage(); //more code here... } catch (Zuora.zForceException ex) { //more code here... }