Deluge Tips Most Developers Don't Know About
Deluge documentation covers the basics well. But after months of daily scripting, you encounter behaviours and patterns that are not obvious from the docs. Here are the ones that changed how I write business logic.
The delay() Function Is Not What You Think
Most developers assume delay() in Deluge works like setTimeout() in JavaScript - pause execution for a moment, then continue. It does not. The delay() function in Deluge is specifically designed for use inside Zoho Flow functions, not standalone Creator or CRM Deluge scripts. Using it incorrectly causes silent failures that are notoriously hard to debug because no error is thrown - execution simply stops.
If you need to pace API calls or add a wait inside Creator, the correct approach is to use scheduled functions with state stored in a record field, not to attempt delays inline. Understanding this single distinction will save hours of debugging.
toJSONList() vs toList() - They Are Not Interchangeable
When you receive JSON from an external API, Deluge parses the response as a string. Calling toJSONList() converts a JSON array string into an iterable Deluge List of Maps. Calling toList() instead gives you a list of raw strings, meaning your subsequent .get() calls on each item will silently fail. This is one of the most common sources of empty values in Deluge functions that call external APIs.
getUrl() Silently Strips Headers in Some Contexts
When using invokeurl with custom headers, Creator's sandbox environment strips certain auth headers during testing but passes them through in production. This means a function that appears to fail in the Creator IDE may work correctly once deployed. Always test Deluge functions that hit external APIs against the actual production endpoint, not only in the sandbox.
Map.put() Overwrites Silently
Calling put() on a Map with an existing key does not warn you - it overwrites. This becomes a problem in loops where you are building a map of results and accidentally use the same key twice. Always check your key generation logic when iterating and building maps. A duplicated key in a loop is one of the hardest bugs to spot in Deluge.
The input Object Behaves Differently Based on Context
In Creator, input refers to the triggering record in on-submit and on-validate contexts. In scheduled functions, there is no input object at all. In CRM custom functions, input is passed explicitly from the trigger. Treating these as equivalent leads to null reference errors that look identical but have different root causes. Always confirm which context your function runs in before relying on input.
The most dangerous Deluge bugs are the ones that fail silently. No exception is thrown, no log entry is written, and the function simply exits without completing. Always verify your critical write operations actually executed by logging the return value of the operation.
Using zoho.loginuserid vs zoho.adminuserid
zoho.loginuserid returns the user currently executing the function. In scheduled functions, this returns the app admin's email. In user-triggered workflows, it returns the logged-in user. Confusing these two in notification logic means your scheduled tasks send emails from the wrong address context, or your notifications attribute actions to the wrong person. Know which one you need before wiring up any notification system.