Nesting one searchRecords function inside another

Nesting one searchRecords function inside another

Hi all,

I am trying to nest one searchRecords function inside another, but when I attempt to save the Deluge I get the following error:

Error at line number:
Improper Statement
Error might be due to missing ';' at end of the line or incomplete expression

My code is:

  1. resellerDetails = Resellers[User == zoho.loginuser];
    resellerName = resellerDetails.Reseller_Name;
    resellerCRMID = resellerDetails.Reseller_CRM_ID;
    //Support Partner
    accountSupportPartner = zoho.crm.searchRecords("Accounts","(Support_Partner:equals:" + resellerCRMID + ")");
    for each arec in accountSupportPartner {
    accountID = arec.get("id");
    accountSupportPartnerSales = zoho.crm.searchRecords("Sales_Orders","(Account_Name:equals:" + accountID + ")");
    for each srec in accountSupportPartnerSales {
    salesRecID = srec.get("id");
    <p><%=salesRedID%>
    }
    }



The first 'for each' function works, but the moment I add 'for each srec in accountSupportPartnerSales {' I get the error above.

Essentially, I am trying to:

1. Look for all Account records that have a particular value in the Support_Partner field.
2. Look up all Sales orders for accounts that have the particular value in the Support_Partner field.


As always, thank you community for your input!