Newer Version Available
QueryResultIterator
The AJAX Toolkit provides the QueryResultIterator object so that you can easily iterate through results without invoking queryMore and queryLocator.
You can use the QueryResultIterator object and functions to iterate over query results returned by the AJAX Toolkit:
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 }- The sforce.connection.query method returns a QueryResult object.
- A QueryResultIterator object is created and passed the QueryResult object.
- The code iterates through the records.