function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lakshmi SundarLakshmi Sundar 

Syntax for multiple tested select statements

Hi
 
Is there any specific syntax to follow when I use multiple nested selected statements in s-control using Jscripts?
cheenathcheenath
This works in AJAX Toolkit 8.0 (winter '07):

  var result = sforce.connection.query("select a.name, a.industry, " +
    "(select c.lastname, c.leadsource from a.contacts c) " +
    "from account a limit 100");

  var ait = new sforce.QueryResultIterator(result);

  while(ait.hasNext()) {
    var account = ait.next();

    var contacts = [];
    if (account.Contacts) {
      var cit = new sforce.QueryResultIterator(account.Contacts);
      while(cit.hasNext()) {
        var contact = cit.next();
        contacts.push(contact.LastName);
      }
    }

    log(account.Name + ": " + contacts.join(","));
  }