Get started now

Conditional Logic in Zoho Deluge: If/Else, Loops and Operators

Conditional logic is what makes automation intelligent. Without conditions, a script does the same thing for every record — which is rarely what you want. With conditions, the script evaluates each record and takes the appropriate action based on its specific data. This guide covers every conditional construct available in Deluge, with examples from real CRM automation use cases. For the broader Deluge reference, see the Deluge cheat sheet. For working examples in a CRM context, see the 5 Deluge scripts guide.

Comparison Operators

OperatorMeaningExample
==Equal tostatus == “Active”
!=Not equal tostage != “Closed Lost”
Greater thanamount 50000
<Less thandaysOverdue < 7
=Greater than or equal toscore >= 80
<=Less than or equal toage <= 30

Logical Operators

OperatorMeaningExample
&&AND — both conditions must be truescore 50 && industry == “Technology”
││OR — at least one condition must be truesource == “Demo” ││ source == “Website”
!NOT — reverses the condition!isConverted

If / Else If / Else Patterns

// Pattern 1: Simple if amount = deal.get(“Amount”); if(amount 100000) { dealCategory = “Enterprise”; } // Pattern 2: If / else if(lead.get(“Lead_Source”) == “Demo Request”) { priority = “High”; } else { priority = “Medium”; } // Pattern 3: If / else if / else chain score = lead.get(“Lead_Score__c”); if(score >= 80) { routing = “Senior Rep”; } else if(score >= 50) { routing = “Standard Rep”; } else if(score >= 20) { routing = “Nurture Queue”; } else { routing = “Disqualify”; } // Pattern 4: Nested conditions if(amount 50000) { if(daysToClose < 30) { urgency = "High value, closing soon"; } else { urgency = "High value, long term"; } }

Working With Lists in Conditions

// Check if a value is in a list premiumIndustries = List(); premiumIndustries.add(“Financial Services”); premiumIndustries.add(“Healthcare”); premiumIndustries.add(“Technology”); industry = contact.get(“Industry”); if(premiumIndustries.contains(industry)) { segment = “Premium”; } else { segment = “Standard”; } // String condition helpers title = contact.get(“Title”).toLowerCase(); isSenior = title.contains(“director”) ││ title.contains(“vp”) ││ title.contains(“head of”) ││ title.contains(“chief”); if(isSenior) { seniorityTier = “C-Suite/Director”; }

For Each Loops

// Iterate a list of CRM records criteria = “(Stage:equals:Proposal Sent)”; deals = zoho.crm.searchRecords(“Deals”, criteria, 1, 200); for each deal in deals { dealId = deal.get(“id”); amount = deal.get(“Amount”); // Conditional action inside the loop if(amount 50000) { // High-value proposal: notify the sales director // … (update or notification logic here) info “High-value proposal: ” + deal.get(“Deal_Name”); } } // Break out of a loop early targetFound = false; for each record in records { if(record.get(“Email”) == “target@example.com”) { targetFound = true; break; } }

Null Checks: Preventing Errors on Missing Data

A Deluge function that tries to call .get() on a null value throws an error and stops executing. Always check for null before accessing nested data from CRM records:

For the complete Deluge syntax reference including string functions, date operations and API calls, see the Deluge cheat sheet. For structured learning, see the Deluge training programme.

// Null check before accessing nested data accountRef = deal.get(“Account_Name”); if(accountRef != null) { accountId = accountRef.get(“id”); account = zoho.crm.getRecordById(“Accounts”, accountId); industry = account.get(“Industry”); } else { industry = “Unknown”; // safe default } // Compact null check using ternary-style logic // Deluge does not have a ternary operator. // Use a variable assignment inside if/else instead: amount = deal.get(“Amount”); safeAmount = 0; if(amount != null) { safeAmount = amount.toNumber(); }

Frequently Asked Questions

Zoho Deluge supports if/else if/else statements, for loops, for each loops, while loops and match/case statements. These cover the full range of conditional logic required for business automation scripts.
Use the toDate() function to ensure both values are Date type, then compare directly: if (date1 > date2). Deluge handles date arithmetic natively — date1.addDay(7) returns a date 7 days later.
Zoho imposes a 60-second execution time limit on Deluge custom functions. Scripts processing large data sets must be designed to handle batches within this limit, using scheduled functions and pagination for bulk operations.
Yes — use isNull() and isEmpty() checks before processing field values. A common source of Deluge errors is attempting to perform operations on null values without checking first. ABR builds all production scripts with null handling as a standard practice.
Yes — complex Deluge scripting is a core ABR development service. Book a free consultation →