Newer Version Available

This content describes an older version of this product. View Latest

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.