Get started now

5 Deluge Scripts Every Zoho CRM Admin Should Know

These five scripts cover the Deluge patterns that appear most frequently in real Zoho CRM implementations. Each one is complete, copy-paste ready and accompanied by a plain-English explanation. Copy any script into your Zoho CRM Function editor, adjust the field API names to match your CRM and deploy via a workflow rule or scheduled trigger. For the foundational concepts that make these scripts readable, see the Deluge introduction guide. For deployment instructions, see the custom functions guide.

Script 1: Calculate Deal Age and Flag Stalled Deals

Use case: Run as a nightly scheduled function to identify deals that have been in the same pipeline stage for more than a defined number of days. Flagged deals are updated with a “Stalled” indicator and a task is created for the deal owner to review.

// Script: flagStalledDeals // Trigger: Scheduled function — run nightly at 7am // Flags deals stuck in the same stage for more than stalledDays stalledDays = 14; // adjust threshold as needed today = zoho.currentdate; // Search for open deals not yet won or lost criteria = “(Stage:not_equal:Closed Won) and (Stage:not_equal:Closed Lost)”; openDeals = zoho.crm.searchRecords(“Deals”, criteria, 1, 200); for each deal in openDeals { dealId = deal.get(“id”); lastModified = deal.get(“Modified_Time”).toDate(); daysSinceUpdate = today.daysBetween(lastModified); if(daysSinceUpdate >= stalledDays) { // Mark the deal as stalled updateMap = Map(); updateMap.put(“Deal_Status__c”, “Stalled”); zoho.crm.updateRecord(“Deals”, dealId, updateMap); // Create a review task for the owner taskData = Map(); taskData.put(“Subject”, “Review stalled deal: ” + deal.get(“Deal_Name”)); taskData.put(“Due_Date”, today.toString(“yyyy-MM-dd”)); taskData.put(“Owner”, {“id”: deal.get(“Owner”).get(“id”)}); taskData.put(“What_Id”, {“id”: dealId, “type”: “Deals”}); zoho.crm.createRecord(“Tasks”, taskData); } }

Script 2: Sync Account Revenue Tier From Deal History

Use case: Update a custom “Revenue Tier” picklist on Account records based on the total value of all closed-won deals linked to that account. Runs as a scheduled function monthly or can be triggered when a deal closes.

// Script: updateAccountRevenueTier // Input parameter: accountId (Long) // Or run as scheduled to process all accounts // Fetch all Closed Won deals for this account criteria = “(Account_Name:equals:” + accountId + “)” + ” and (Stage:equals:Closed Won)”; wonDeals = zoho.crm.searchRecords(“Deals”, criteria, 1, 200); // Sum the deal values totalRevenue = 0; for each deal in wonDeals { dealAmount = deal.get(“Amount”); if(dealAmount != null) { totalRevenue = totalRevenue + dealAmount.toNumber(); } } // Assign tier based on total revenue tier = “Bronze”; if(totalRevenue >= 100000) { tier = “Gold”; } else if(totalRevenue >= 25000) { tier = “Silver”; } // Update the Account record updateMap = Map(); updateMap.put(“Revenue_Tier__c”, tier); updateMap.put(“Lifetime_Revenue__c”, totalRevenue); zoho.crm.updateRecord(“Accounts”, accountId, updateMap);

Script 3: Send a Personalised Follow-Up Email Based on CRM Data

Use case: Send a contextual follow-up email to a contact that references their company name, the specific deal they discussed and the assigned account manager’s name — personalisation that a standard email template with basic merge fields cannot achieve when the data comes from related records.

// Script: sendPersonalisedFollowUp // Input parameter: dealId (Long) // Trigger: Workflow rule when deal stage changes to “Proposal Sent” deal = zoho.crm.getRecordById(“Deals”, dealId); contactId = deal.get(“Contact_Name”).get(“id”); contact = zoho.crm.getRecordById(“Contacts”, contactId); // Build personalised email body firstName = contact.get(“First_Name”); companyName = deal.get(“Account_Name”).get(“name”); dealName = deal.get(“Deal_Name”); ownerName = deal.get(“Owner”).get(“name”); contactEmail = contact.get(“Email”); emailBody = “Hi ” + firstName + “, ” + “Thank you for our conversation about ” + dealName + “. ” + “As discussed, I’ve put together a proposal for ” + companyName + “. ” + “Please review the attached document and let me know if you have any questions. ” + “I’ll follow up on Thursday to discuss your thoughts. ” + “Best regards, ” + ownerName; sendmail [ from: zoho.adminuserid to: contactEmail subject: “Your proposal — ” + companyName message: emailBody ];

Script 4: Populate Lead Score Based on Profile Fields

Use case: Calculate and store a lead score based on field values when a lead is created or updated. Complements Zia AI scoring with rule-based scoring that reflects your specific qualification criteria.

// Script: calculateLeadScore // Input parameter: leadId (Long) // Trigger: Workflow rule on Lead create or field change lead = zoho.crm.getRecordById(“Leads”, leadId); score = 0; // Score by company size companySize = lead.get(“No_of_Employees”).toString(); if(companySize.toLong() >= 100) { score = score + 20; } else if(companySize.toLong() >= 20) { score = score + 10; } // Score by lead source leadSource = lead.get(“Lead_Source”); if(leadSource == “Demo Request”) { score = score + 30; } else if(leadSource == “Website Contact Form”) { score = score + 20; } else if(leadSource == “Cold Outreach”) { score = score – 10; } // Score by industry fit industry = lead.get(“Industry”); targetIndustries = List(); targetIndustries.add(“Professional Services”); targetIndustries.add(“Technology”); targetIndustries.add(“Healthcare”); if(targetIndustries.contains(industry)) { score = score + 20; } // Score by title/seniority title = lead.get(“Title”).toLowerCase(); if(title.contains(“director”) ││ title.contains(“vp”) ││ title.contains(“head of”)) { score = score + 15; } // Write score back to the lead record updateMap = Map(); updateMap.put(“Lead_Score__c”, score); zoho.crm.updateRecord(“Leads”, leadId, updateMap);

Script 5: Rollup Activity Count From Contacts to Account

Use case: Maintain an “Engagement Activity Count” field on Account records that reflects the total number of calls, meetings and emails logged across all contacts linked to the account. Updated as a scheduled nightly function to keep the account-level engagement metric current for reporting.

For training on adapting and extending these scripts for your specific CRM configuration, see the Deluge training programme. For help deploying these functions in your production CRM, contact the ABR Deluge development team.

// Script: rollupAccountActivityCount // Input parameter: accountId (Long) // Can be called from a scheduled function that iterates all accounts // Get all contacts linked to this account criteria = “(Account_Name:equals:” + accountId + “)”; contacts = zoho.crm.searchRecords(“Contacts”, criteria, 1, 200); totalActivities = 0; for each contact in contacts { contactId = contact.get(“id”); // Count activities for this contact activityCriteria = “(Who_Id:equals:” + contactId + “)”; activities = zoho.crm.searchRecords(“Calls”, activityCriteria, 1, 200); totalActivities = totalActivities + activities.size(); meetings = zoho.crm.searchRecords(“Events”, activityCriteria, 1, 200); totalActivities = totalActivities + meetings.size(); } // Update the Account with the total activity count updateMap = Map(); updateMap.put(“Engagement_Activity_Count__c”, totalActivities); zoho.crm.updateRecord(“Accounts”, accountId, updateMap);

Frequently Asked Questions

Basic familiarity with Zoho CRM’s function editor and the ability to read Deluge syntax. If you are new to Deluge, start with the Zoho Deluge Introduction → before applying these scripts.
The scripts in this guide are working examples that can be adapted for your CRM. Field names, module names and logic will need to be adjusted to match your specific configuration. ABR recommends testing in a sandbox environment before deploying to production.
Zoho CRM Enterprise and above includes a sandbox — a copy of your CRM environment where you can test configuration changes and scripts without affecting live data. Always test Deluge scripts in sandbox before production deployment.
A poorly written script that updates records without proper condition checks can modify unintended records. This is why testing in sandbox is essential. ABR includes sandboxing and rollback planning in all custom function development.