How do I fetch records from Zoho CRM in Deluge and handle an empty result?
I search Deals by stage and then loop over the response. The function fails when nothing matches.

Answer
`zoho.crm.searchRecords` returns a list. When no record matches, the list is empty, so check it before you loop or read fields.
1. Build the criteria string as `(Field:operator:value)`.
2. Call `searchRecords` with the module, criteria, page and page size.
3. Return early with `isEmpty()`.
4. Wrap nullable fields in `ifnull()` before converting them.
Page size is capped at 200 records per call, so loop over pages for larger sets.
Zoho Deluge solution
// Sum the amount of all Closed Won deals (Zoho Deluge)
criteria = "(Stage:equals:Closed Won)";
response = zoho.crm.searchRecords("Deals", criteria, 1, 200);
if(response.isEmpty())
{
info "No matching deals found";
return;
}
total = 0;
for each deal in response
{
total = total + ifnull(deal.get("Amount"), 0).toDecimal();
}
info "Closed Won total: " + total;Edited by Jack · joysait@rediffmail.com