Get started now

Automating Zoho CRM with Scheduled Deluge Functions

A scheduled function is a Deluge script that runs automatically on a defined schedule — every day at 7am, every Monday morning, on the first of each month. Unlike workflow rules, which fire in response to record changes, scheduled functions fire on a clock. They are the right tool for automation that needs to run across many records at a defined time — nightly data cleanup, weekly performance reports, monthly territory rebalancing or any batch process that does not map to a single triggering event. This guide covers how scheduled functions work, how to write one and the patterns that make them reliable in production. For the foundational Deluge concepts, see the Deluge introduction guide. For the full automation context, see the Zoho Deluge scripting hub.

How Scheduled Functions Differ From Workflow-Triggered Functions

CharacteristicWorkflow-Triggered FunctionScheduled Function
What triggers itA record event (create, edit, field change)A clock (time, day, date pattern)
Records processedOne record at a time (the triggering record)Multiple records — the function queries and iterates
Execution contextFires in real time when the event occursFires at the configured schedule regardless of events
Best forReal-time responses to individual record changesBatch operations across many records on a regular schedule
Common use casesUpdate related record, send notification, calculate fieldNightly cleanup, weekly report, monthly rebalancing

Setting Up a Scheduled Function in Zoho CRM

  • Go to Setup → Developer Space → Functions. Create a new function or open an existing one.
  • In the function’s trigger settings, select “Time Based” as the trigger type.
  • Set the schedule. Options include: daily at a specific time, weekly on a specific day and time, monthly on a specific date and time, or a custom cron expression for more complex patterns.
  • Set the timezone. Schedule times reference the timezone you configure — set it to match your business’s primary timezone.
  • Save and activate. The function will next execute at the next occurrence of the configured schedule.

A Complete Scheduled Function: Nightly Overdue Deal Alert

This function runs every weekday morning at 8am. It identifies deals whose close date has passed without being marked Closed Won or Closed Lost, updates a custom “Overdue” field and creates a task for each deal’s owner to take action.

// Scheduled function: processOverdueDeals // Schedule: Daily at 08:00 (business days) today = zoho.currentdate; // Find deals where close date is in the past and deal is still open criteria = “(Close_Date:less_than:” + today.toString(“yyyy-MM-dd”) + “)” + ” and (Stage:not_equal:Closed Won)” + ” and (Stage:not_equal:Closed Lost)”; overdueDeals = zoho.crm.searchRecords(“Deals”, criteria, 1, 200); processedCount = 0; for each deal in overdueDeals { dealId = deal.get(“id”); dealName = deal.get(“Deal_Name”); ownerId = deal.get(“Owner”).get(“id”); closeDate = deal.get(“Close_Date”); // Mark deal as overdue updateMap = Map(); updateMap.put(“Is_Overdue__c”, true); updateMap.put(“Days_Overdue__c”, today.daysBetween(closeDate.toDate())); zoho.crm.updateRecord(“Deals”, dealId, updateMap); // Create an action task for the owner (only if no overdue task exists) taskSubject = “ACTION REQUIRED: Update close date — ” + dealName; taskData = Map(); taskData.put(“Subject”, taskSubject); taskData.put(“Due_Date”, today.toString(“yyyy-MM-dd”)); taskData.put(“Priority”, “High”); taskData.put(“Owner”, {“id”: ownerId}); taskData.put(“What_Id”, {“id”: dealId, “type”: “Deals”}); zoho.crm.createRecord(“Tasks”, taskData); processedCount = processedCount + 1; } // Log the execution result info “Processed ” + processedCount + ” overdue deals on ” + today.toString(“yyyy-MM-dd”);

Key Patterns for Reliable Scheduled Functions

Handle the 200-Record Search Limit

Zoho CRM’s searchRecords function returns a maximum of 200 records per call. If your function needs to process more than 200 records, implement pagination: loop through result pages until you get an empty response.

// Paginated record search pattern pageNum = 1; pageSize = 200; hasMore = true; while(hasMore) { records = zoho.crm.searchRecords(“Deals”, criteria, pageNum, pageSize); if(records.size() == 0) { hasMore = false; } else { for each record in records { // process each record here } pageNum = pageNum + 1; } }

Log Execution for Monitoring

Scheduled functions run without a user watching them. Add an info statement at the end of every scheduled function that records what was processed — it appears in the execution log for that function run.

Guard Against Duplicate Processing

If a scheduled function creates records (tasks, activities) and runs daily, it can create duplicates if the condition that triggers creation persists across multiple days. Add a check before creating any record: search for an existing record with the same key attributes and skip creation if one already exists.

Frequently Asked Questions

A scheduled function is a Deluge script that runs automatically at a defined time interval — daily, weekly, hourly or at a specific date/time. It runs without any user trigger, making it suitable for bulk data updates, automated reports and time-based business logic.
Daily pipeline health checks (flag deals with no activity in 14 days), weekly data quality reports (identify records with missing required fields), monthly KPI calculations (update a score field across all active contacts), and automated list cleaning (suppress bounced email addresses).
In Zoho CRM: Settings → Developer Space → Scheduled Functions → New Scheduled Function. Write the Deluge script, set the schedule (frequency and time), and activate. The function runs automatically on the defined schedule.
Yes — Zoho CRM imposes API call limits and execution time limits on scheduled functions. Scripts that process large numbers of records need to be designed to handle pagination and stay within execution limits. ABR builds production-grade scheduled functions with these constraints in mind.
Yes — scheduled function development is part of ABR’s Zoho CRM development services. Book a free consultation →