Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

QueryResultIterator

Iterate over query results returned by the AJAX Toolkit without invoking queryMore and queryLocator.
1var result = sforce.connection.query("select id, name from account");
2    var it = new sforce.QueryResultIterator(result);
3
4    while (it.hasNext()) {
5        var account = it.next();
6        sforce.debug.log(account.Name);
7    }
  1. The sforce.connection.query method returns a QueryResult object.
  2. A QueryResultIterator object is created and passed the QueryResult object.
  3. The code iterates through the records.