Title: Deluge Script: Syntax Basics and 10 Real Examples
URL: https://zudoworks.com/insights/deluge-script-examples/
Description: What Deluge script is, where it runs in Zoho, the syntax basics and 10 real scripts for CRM, Creator and Books, with code to adapt. Checked Nov 2026.
Updated: 2026-11-25

# Deluge Script: What It Is, Syntax Basics and 10 Real Examples for Zoho

Deluge script is the language behind Zoho CRM functions, Zoho Creator apps, Zoho Books custom functions and close to 40 other Zoho services. This guide explains what Deluge is, where you write it and the syntax you need, then gives ten scripts based on the automations we write most often.

By [Arunkumar V](https://zudoworks.com/about/arunkumar-v/), founder and CTO of Zudo Works
Published 8 October 2026 · Updated 25 November 2026 · 10 min read

## Quick answer

Deluge script is Zoho's own scripting language, short for Data Enriched Language for the Universal Grid Environment. You write it in a browser editor inside Zoho CRM, Creator, Books, Desk and close to 40 other Zoho services to automate work: create records across apps, validate forms, send reminders and call outside APIs with invokeurl.

![Six of ten reusable Deluge scripts, including invoices from won deals, duplicate checks and API calls](https://zudoworks.com/Asset/img/insights/deluge-script-examples.webp)

Small Deluge functions remove the manual steps between Zoho apps.

## On this page

1. [What is Deluge script?](#what-is-deluge)
2. [Deluge syntax basics](#syntax-basics)
3. [Before you start](#before-you-start)
4. [1. Create a Zoho Books invoice when a CRM deal is won](#deal-to-invoice)
5. [2. Flag duplicate contacts by email](#block-duplicates)
6. [3. Create a follow-up task when a lead is contacted](#follow-up-task)
7. [4. Email owners about deals past their closing date](#stale-deals)
8. [5. Call an external API and save the result](#call-api)
9. [6. Validate a Zoho Creator form before it is saved](#creator-validation)
10. [7. Keep an activity log in Zoho Creator](#creator-insert)
11. [8. Totals and counts across related records](#creator-aggregate)
12. [9. Working with dates](#dates)
13. [10. Handle errors instead of failing silently](#error-handling)
14. [Good habits for maintainable Deluge](#good-habits)
15. [How we test and deploy Deluge safely](#testing)
16. [Frequently asked questions](#faq)

Deluge (Data Enriched Language for the Universal Grid Environment) is Zoho’s own scripting language. It is deliberately simple: maps, lists, loops and built-in tasks such as `zoho.crm.getRecordById` or `zoho.books.createRecord` that talk to other Zoho apps without you handling authentication yourself.

The examples below are simplified versions of scripts we use in client projects. Field API names in your account will differ, so treat them as patterns, not copy-and-paste solutions. Always test in a sandbox or on test records first.

## What is Deluge script?

Zoho describes Deluge, short for Data Enriched Language for the Universal Grid Environment, as “an online scripting language that links 50+ products in the Zoho suite” on its [Deluge page](https://www.zoho.com/deluge). Its help pages list close to 40 Zoho services that run it, among them Zoho CRM, Creator, Books, Desk, Inventory, Projects, People, Cliq, Bigin and Flow ([Zoho services that support Deluge](https://www.zoho.com/deluge/help/zoho-services-supporting-deluge.html), checked 25 November 2026).

Three things set it apart from a general language such as JavaScript or Python:

- **It runs inside Zoho.** You write and save scripts in a browser editor in the Zoho app itself. There is nothing to install or host.
- **Zoho apps are built in.** Tasks such as `zoho.crm.getRecordById` and `zoho.books.createRecord` read and write records in other Zoho apps, with sign-in handled by Zoho or by a named connection.
- **The editor helps you write it.** Zoho says the editor “lets you drag and drop syntax”, with guided scripting and code snippets, and offers an [online compiler](https://deluge.zoho.com/tryout) for practising outside an app.

Deluge is used for the jobs that point-and-click workflow rules cannot do on their own: logic across several records or apps, calls to outside systems and calculations. When to choose a script over a no-code tool is covered in [Zoho Flow vs Deluge](https://zudoworks.com/insights/zoho-flow-vs-deluge/).

## Deluge syntax basics

Most scripts use a handful of building blocks. This short script uses all of them:

```
// Variables need no type declaration
total = 0;
customer = "Acme Ltd";

// A map holds key and value pairs, like a record
order = Map();
order.put("Customer", customer);
order.put("Amount", 1200);

// A list holds values in order
lines = List();
lines.add(500);
lines.add(700);

// Loop through a list
for each line in lines
{
    total = total + line;
}

// Conditions, with a default for empty values
discount = ifnull(order.get("Discount"), 0);
if (total > 1000 && discount == 0)
{
    info "Large order without a discount";
}
else if (total == 0)
{
    info "Empty order";
}
```

| Building block | What it does | Our detailed guide |
| --- | --- | --- |
| Maps and lists | Hold records and collections; `put`, `get` and `add` change them | Examples 1, 5 and 7 below |
| if, else if, else | Branch on a value; `ifnull` supplies a default when a field is empty | [Deluge if, else and ifnull](https://zudoworks.com/insights/deluge-if-else-ifnull/) |
| for each | Repeats for every item in a list; there is no general while loop | [Deluge for each and while loops](https://zudoworks.com/insights/deluge-for-each-while-loop/) |
| try and catch | Catches a failed task so the script can log it or retry | [Deluge try catch](https://zudoworks.com/insights/deluge-try-catch-error-handling/) |
| invokeurl | Calls any REST API, usually through a named connection | [Deluge invokeurl](https://zudoworks.com/insights/deluge-invokeurl-api-calls/) |
| info | Prints a value while you test | Used throughout the examples |

## Before you start

- **Where Deluge runs:** in Zoho CRM as functions attached to workflow rules, buttons, Blueprint transitions or schedules; in Zoho Creator on form and report events; in Zoho Books as custom functions and workflow actions.
- **Field names:** use API names, not display labels. In Zoho CRM you can see them under *Setup > Developer Hub > APIs*.
- **Connections:** calls to other services, including some Zoho apps, use a named connection that stores OAuth credentials. Create it once under *Connections* and reference it by name.
- **Debugging:** use `info` to print values while testing. Remove noisy output before going live.
- **Still current:** we re-checked these examples against Zoho’s Deluge release notes on 16 October 2026. None of the tasks used here has been deprecated. In April 2026 Zoho added 13 Zoho CRM integration tasks built on version 8 of the CRM API, and in August 2026 a `throw` statement, which example 10 now uses.

## 1. Create a Zoho Books invoice when a CRM deal is won

Use this as a workflow function on the Deals module, triggered when the stage changes to *Closed Won*. It assumes each account stores its Zoho Books customer ID in a custom field.

```
// Argument: dealId (mapped to the Deal ID in the workflow)
deal = zoho.crm.getRecordById("Deals", dealId);
account = zoho.crm.getRecordById("Accounts", deal.get("Account_Name").get("id"));
customerId = account.get("Books_Customer_ID");
if (customerId == null)
{
    info "No Books customer linked to this account";
    return;
}
lineItem = Map();
lineItem.put("name", deal.get("Deal_Name"));
lineItem.put("rate", deal.get("Amount"));
lineItem.put("quantity", 1);
items = List();
items.add(lineItem);
invoice = Map();
invoice.put("customer_id", customerId);
invoice.put("reference_number", deal.get("Deal_Name"));
invoice.put("line_items", items);
response = zoho.books.createRecord("invoices", "YOUR_ORG_ID", invoice, "zbooks");
info response.get("message");
```

**Why it helps:** no one re-types deal values into accounting, and the invoice reference ties back to the deal.

## 2. Flag duplicate contacts by email

Zoho CRM can block exact duplicates on unique fields, but contacts often arrive through imports and integrations with slightly different data. This function runs on contact creation and flags the new record if another contact already has the same email.

```
// Argument: contactId
contact = zoho.crm.getRecordById("Contacts", contactId);
email = contact.get("Email");
if (email != null && email != "")
{
    matches = zoho.crm.searchRecords("Contacts", "(Email:equals:" + email + ")");
    if (matches.size() > 1)
    {
        update = Map();
        update.put("Possible_Duplicate", true);
        zoho.crm.updateRecord("Contacts", contactId, update);
    }
}
```

A saved view filtered on *Possible Duplicate* then gives an admin a daily clean-up list.

## 3. Create a follow-up task when a lead is contacted

```
// Argument: leadId. Trigger: Lead Status changes to "Contacted"
lead = zoho.crm.getRecordById("Leads", leadId);
task = Map();
task.put("Subject", "Follow up with " + lead.get("Full_Name"));
task.put("Due_Date", zoho.currentdate.addDay(3).toString("yyyy-MM-dd"));
task.put("What_Id", leadId);
task.put("$se_module", "Leads");
task.put("Owner", lead.get("Owner").get("id"));
zoho.crm.createRecord("Tasks", task);
```

**Why it helps:** follow-ups stop depending on memory, and managers can report on overdue tasks.

## 4. Email owners about deals past their closing date

Schedule this function to run every weekday morning.

```
today = zoho.currentdate.toString("yyyy-MM-dd");
deals = zoho.crm.searchRecords("Deals", "((Closing_Date:less_than:" + today + ")and(Stage:not_equal:Closed Won)and(Stage:not_equal:Closed Lost))");
for each deal in deals
{
    owner = deal.get("Owner");
    sendmail
    [
        from: zoho.adminuserid
        to: owner.get("email")
        subject: "Deal past closing date: " + deal.get("Deal_Name")
        message: "Please update the stage or closing date for " + deal.get("Deal_Name") + "."
    ]
}
```

Search results are paginated, so for large pipelines loop through pages with the page parameter of `searchRecords`. Our guide to [Deluge for each loops and the while loop workaround](https://zudoworks.com/insights/deluge-for-each-while-loop/) shows the paging pattern.

## 5. Call an external API and save the result

This pattern fetches data from another system with `invokeurl` and writes it back to the record. Here a custom button looks up a company in an external service using a stored connection. Calls like this use API credits, as our guide to [Zoho CRM API limits](https://zudoworks.com/insights/zoho-crm-api-limits/) explains. For status codes, timeouts, JSON bodies and the ports Zoho allows, see our full [Deluge invokeurl guide](https://zudoworks.com/insights/deluge-invokeurl-api-calls/).

```
// Argument: accountId
account = zoho.crm.getRecordById("Accounts", accountId);
response = invokeurl
[
    url: "https://api.example.com/companies?domain=" + account.get("Website")
    type: GET
    connection: "example_api"
];
if (response.get("employees") != null)
{
    update = Map();
    update.put("Employees", response.get("employees"));
    zoho.crm.updateRecord("Accounts", accountId, update);
}
return "Company details updated";
```

## 6. Validate a Zoho Creator form before it is saved

Put this in the form’s *On Validate* event. It stops the record from saving and shows a message.

```
if (input.Quantity <= 0)
{
    alert "Quantity must be at least 1.";
    cancel submit;
}
if (input.Delivery_Date < zoho.currentdate)
{
    alert "Delivery date cannot be in the past.";
    cancel submit;
}
```

## 7. Keep an activity log in Zoho Creator

In the *On Success* event of an Orders form, add a row to a separate log form. This gives you a simple audit trail that reports and dashboards can use.

```
insert into Activity_Log
[
    Added_User = zoho.loginuser
    Order = input.ID
    Action = "Order " + input.Status
    Logged_At = zoho.currenttime
];
```

## 8. Totals and counts across related records

Creator can fetch and aggregate records directly. This example updates a customer’s open order count and total value whenever an order is saved.

```
openOrders = Orders[Customer == input.Customer && Status == "Open"];
customer = Customers[ID == input.Customer];
customer.Open_Orders = openOrders.count();
customer.Open_Value = Orders[Customer == input.Customer && Status == "Open"].sum(Amount);
```

## 9. Working with dates

Date logic comes up in almost every project: SLAs, renewals, reminders. A few useful patterns:

```
start = toDate("2026-01-15", "yyyy-MM-dd");
renewal = start.addYear(1);
daysLeft = zoho.currentdate.daysBetween(renewal);
if (daysLeft <= 30)
{
    info "Renewal due in " + daysLeft + " days";
}
weekday = zoho.currentdate.getDayOfWeek();  // 1 = Sunday ... 7 = Saturday
```

### Working with text

Text handling comes a close second: splitting reference numbers, cleaning imported values, building email subjects. Two built-in functions do much of the work. [`subString`](https://www.zoho.com/deluge/help/functions/string/substring.html) returns part of a text by position; indexes start at 0, the start index is included and the end index is not. [`getSuffix`](https://www.zoho.com/deluge/help/functions/string/getsuffix.html) returns everything after the first match of a search text, is case-sensitive, and returns null when there is no match, so pair it with `ifnull`.

```
ref = "INV-2026-0042";
year = ref.subString(4, 8);              // "2026"
number = ifnull(ref.getSuffix("2026-"), ""); // "0042"
subject = "Invoice " + number + " for " + year;
```

## 10. Handle errors instead of failing silently

Scripts that call other systems will eventually meet a timeout or an unexpected response. Wrap risky calls in `try` and `catch`, and use `throw` to treat an error reply as a failure too, so both cases reach the same alert.

```
try
{
    response = zoho.books.createRecord("invoices", "YOUR_ORG_ID", invoice, "zbooks");
    if (response.get("code") != 0)
    {
        throw "Books returned an error: " + response.get("message");
    }
}
catch (e)
{
    sendmail
    [
        from: zoho.adminuserid
        to: "admin@yourcompany.com"
        subject: "Invoice automation failed"
        message: "Deal: " + dealId + "
Error: " + e.message
    ]
}
```

Without the `throw`, an error reply from Zoho Books would not be an exception, and the script would carry on as if the invoice existed. Inside `catch`, the exception’s `message` holds the text, and its `type` tells you whether your script or Deluge raised it. Our [Deluge try catch and throw guide](https://zudoworks.com/insights/deluge-try-catch-error-handling/) covers error handling in full.

New to functions? Our [Zoho CRM custom functions guide](https://zudoworks.com/insights/zoho-crm-custom-functions/) explains the categories, timeouts and credits, and how to attach a function to a workflow rule.

## Good habits for maintainable Deluge

- **One job per function.** Small functions are easier to test and reuse.
- **Comment the why, not the what.** The next developer can read the code; they can’t read your reasons.
- **Check for nulls** before calling `.get()` on lookups that may be empty.
- **Mind the limits.** Each Zoho product sets limits on function execution time, API calls and emails per day. Batch work in scheduled functions rather than firing one call per record.
- **Keep a list of automations**: name, trigger, what it does, who owns it. It is the most useful document in any Zoho account.
- **Know when a script is the wrong tool.** Simple field updates and emails are easier to maintain as workflow rules, and AI-driven steps are covered in [connecting Zoho CRM to ChatGPT](https://zudoworks.com/insights/connect-zoho-crm-to-chatgpt/).

If you have scripts that work but nobody understands, or automations you would like to build, our [Deluge development](https://zudoworks.com/deluge-development/) service covers new functions, reviews and fixes.

## How we test and deploy Deluge safely

1. **Write against test records first.** Create a few records that cover the normal case and the edge cases: empty lookups, zero amounts, missing emails.
2. **Use the function editor’s test run** with a test record ID, and print key values with `info`.
3. **Attach the function to its trigger** (workflow, button, schedule) only after it behaves correctly in isolation.
4. **Check limits.** If a scheduled function processes many records, test it with a realistic volume.
5. **Document it:** name, trigger, purpose, fields touched and owner, in your automation list.
6. **Watch the first week** of live runs, especially anything that sends email or creates records in another app.

## Frequently asked questions

## Frequently asked questions

What is Deluge in Zoho?

Deluge is Zoho's scripting language. It runs inside Zoho CRM, Zoho Creator, Zoho Books, Zoho Desk and other Zoho apps, and has built-in tasks for reading and writing records across Zoho products, sending email and calling external APIs.

What is Deluge scripting used for?

Deluge scripting automates work inside Zoho apps where point-and-click rules are not enough: creating records in one app from another, validating Zoho Creator forms, calculating totals, sending scheduled reminders and calling outside APIs. Scripts run on events such as a record being saved, a button click, a Blueprint transition or a schedule.

Where can I practise Deluge online?

Zoho offers an online compiler at deluge.zoho.com/tryout, linked from its Deluge page, where you can run scripts outside any app. Inside an account, the function editors in Zoho CRM, Creator and Books let you save and test scripts on test records, with info statements to print values.

How do I get part of a text in Deluge?

Use subString(start, end) for a position: indexes start at 0, the start is included and the end is not, so "INV-2026".subString(4, 8) returns "2026". Use getSuffix to take everything after a search text. getSuffix is case-sensitive and returns null when the text is not found.

Is Deluge hard to learn?

Not for anyone who has written a spreadsheet formula or a little code. The syntax is small: maps, lists, conditions, loops and built-in tasks. The harder part is knowing each Zoho app's field API names, limits and events.

Where do I write Deluge in Zoho CRM?

Under Setup, in Developer Hub, then Functions. Functions can be attached to workflow rules, custom buttons, Blueprint transitions, related lists or schedules.

Can Deluge call non-Zoho APIs?

Yes. The invokeurl task calls any REST API. Store credentials in a named connection so tokens are refreshed automatically and secrets are not written into the script.

**Related services:** [Deluge development](https://zudoworks.com/deluge-development/) · [Business process automation](https://zudoworks.com/business-process-automation/) · [Zoho integrations](https://zudoworks.com/zoho-integrations/) · [Zoho development](https://zudoworks.com/zoho-development/)

![Arunkumar V](https://zudoworks.com/Asset/img/team/arunkumar-v-avatar.webp)

[Arunkumar V](https://zudoworks.com/about/arunkumar-v/), Founder and CTO, Zudo Works

Arunkumar builds ZMOS, Zoho Creator apps, Zoho CRM systems, Deluge automations and integrations for businesses in the US, UK, Australia, New Zealand and India. He received the Master of Creator award at the Zoho Creator Partner Hackathon 2025. Before founding Zudo Works in 2026 he worked at Teleperformance, at iOPEX Technologies and at a Zoho partner firm, and as a senior supervisor in manufacturing at Brakes India Private Limited, so he knows how a production floor runs.

[Arunkumar V on LinkedIn](https://www.linkedin.com/in/arunkumar-v-cto) [About Arunkumar](https://zudoworks.com/about/arunkumar-v/)

Zoho and the other product names in this article are trademarks of their respective owners. Facts about other products were checked against the vendors' own pages on the dates stated; tell us if something has changed.

## Related articles

[Zoho Creator vs Microsoft Power Apps: An Honest Comparison for Growing Businesses](https://zudoworks.com/insights/zoho-creator-vs-power-apps/)
[Migrating from HubSpot or Salesforce to Zoho CRM: A Step-by-Step Plan](https://zudoworks.com/insights/migrate-hubspot-salesforce-to-zoho-crm/)
[How Much Does a Zoho CRM Implementation Cost? A Transparent Breakdown](https://zudoworks.com/insights/zoho-crm-implementation-cost/)
[Zoho CRM Custom Functions: A Beginner's Guide to Triggers, Limits and Your First Function](https://zudoworks.com/insights/zoho-crm-custom-functions/)
