What Deluge Is
Zoho’s scripting language — runs across CRM, Creator, Flow, Catalyst (as Embedded Functions), Desk, Books, and most Zoho apps. Pythonic syntax with built-in API tasks for Zoho operations and external HTTP calls. Strongly typed at runtime, weakly typed at declaration. Deluge code lives inline (Workflow custom function), in Connections (reusable integration credentials), or as standalone Functions invoked from buttons, schedules, or APIs.
Variables and Types
Types: String, Int, Long, Decimal, Boolean, Map, List, DateTime, Date, Time, Key-Value (record-like), and File. Declaration is implicit — v = "hello" creates a String. Watch for type coercion quirks: "5" + 3 produces “53” (string concatenation), not 8. Always cast explicitly when arithmetic matters: "5".toLong() + 3 = 8. Maps are unordered; Lists preserve insertion order. The null value differs from empty string and missing key — myMap.get("missing") returns null, myMap.get("missing", "default") returns “default”.
Integration Tasks
invokeurl for HTTP, sendmail for email, zoho.crm.createRecord / updateRecord / getRecordById / searchRecords for CRM ops, zoho.books.* for Books, zoho.desk.* for Desk. Each task has named parameters. Error responses come back as a structured Map with code and message keys.
// Pattern: external API call with error handling
try {
response = invokeurl
[
url: "https://api.example.com/customers/" + customer_id
type: GET
headers: {"Authorization": "Bearer " + api_key}
connection: "example_api_oauth"
];
if (response.get("status") == "ok") {
zoho.crm.updateRecord("Accounts", account_id, {
"External_Id": response.get("data").get("id"),
"Last_Synced": zoho.currenttime
});
} else {
info "API returned non-ok: " + response.toString();
sendmail [from: zoho.adminuserid, to: "[email protected]", subject: "Sync failure for account " + account_id, message: response.toString()];
}
} catch (e) {
info "Exception in sync for account " + account_id + ": " + e.toString();
sendmail [from: zoho.adminuserid, to: "[email protected]", subject: "Sync exception", message: e.toString()];
}
Error Handling
try/catch blocks catch runtime exceptions. Use sendmail on catch to alert when a task fails — silent failures in production Deluge are common and painful. Always log caught exceptions with context (record ID, function name, input parameters) before re-raising or alerting. The Function Log captures info and print output per execution; structured logging with consistent prefixes makes the log searchable.
Performance
Deluge scripts have time limits — 300 seconds for workflow-triggered, 600 seconds for scheduler-triggered, 30 seconds for client-side embedded. API calls within a function count against the org’s CRM API daily quota. Common performance pitfalls: nested loops over searchRecords results (O(n²) API calls), no pagination on large result sets (Deluge paginates internally but defaults to 200/page), and re-fetching the same record multiple times within one function.
Patterns That Save Time
Use Map literals for clean record updates: zoho.crm.updateRecord("Deals", id, {"Stage": "Won", "Closing_Date": today}). Use List.collect() and List.filter() for transformations instead of explicit loops. Cache external API responses in a Catalyst Cache or Creator form when the same data is referenced repeatedly within a session. Break long jobs into Zoho Flow chains where each Deluge function handles a single step.
Common Failure Modes
Connection token expiry on external APIs — establish a quarterly re-auth check. Schema drift where a function references Field_X that’s been renamed — establish a Custom Function Impact check in your schema migration process. Over-broad search criteria producing 10k+ results that the function then iterates over, blowing the time limit.
What to do this week
Add structured exception logging to your three highest-volume Deluge functions, pull the Function Log for the last 7 days and identify any function approaching the time limit, and audit your Connections for tokens expiring in the next 30 days.