[object Object]

What Custom Functions Do

Deluge scripts that execute in response to workflow triggers, button clicks, schedules, related-list buttons, or invocations from other functions. Extend CRM beyond declarative automation when you need branching logic, external API calls, multi-record operations, or computations that don’t fit the formula field model.

Invocation Patterns

Six invocation contexts: Workflow Rules (record context passed in), Custom Buttons on detail pages (current record passed in), Related List Custom Buttons (parent record + selected related records), Schedulers (no record context — function runs on cron), Web Tabs (browser-triggered), and Function-from-Function (programmatic invocation via zoho.crm.invokeConnector or function URL). The trigger context determines what’s available in the input map.

// Custom function invoked from a workflow on Deal create
deal_id = input.deal_id;
deal = zoho.crm.getRecordById("Deals", deal_id);

// External API call to enrich account data
account_name = deal.get("Account_Name").get("name");
enrichment = invokeurl
[
    url: "https://api.clearbit.com/v2/companies/find?name=" + account_name
    type: GET
    headers: {"Authorization": "Bearer " + clearbit_key}
];

if (enrichment.get("status") != "error") {
    update_data = Map();
    update_data.put("Industry", enrichment.get("category").get("industry"));
    update_data.put("Employee_Count", enrichment.get("metrics").get("employees"));
    zoho.crm.updateRecord("Accounts", deal.get("Account_Name").get("id"), update_data);
}

Testing

Create a test data record matching your function’s input expectations. Run the function from Setup → Functions → Test Function with a payload. Inspect the Function Log — every execution captures inputs, outputs, exceptions, and execution time. Production debugging relies entirely on these logs, so add info statements at decision points and around external API calls.

Common Patterns

Complex validations that exceed the formula field’s capability (e.g. cross-module checks). External API calls for enrichment (Clearbit, ZoomInfo), payment processing (Stripe), or carrier rate lookup (FedEx). Bulk data transformations triggered by a button (e.g. “Recalculate all deal probabilities”). Rolling up related records (sum of all line item amounts into a Deal field). Don’t try to do everything in one function — break responsibilities into composable functions and chain them.

Performance Limits

Each function execution has a 300-second timeout (workflow-triggered) or 600-second (scheduler-triggered). API calls within a function count against the org’s CRM API daily quota. Memory limit is 50MB per execution. Long-running batch jobs (>5 minutes typical) belong in Zoho Flow or Catalyst, not in a CRM Custom Function.

Governance

Document each function’s purpose, triggering context, dependencies (external APIs, OAuth connections), and owner. Orphan functions accumulate as admins rotate; quarterly review with deprecation workflow keeps the inventory clean. Function naming convention (e.g. module_action_purpose like Deals_OnCreate_EnrichAccount) helps discovery in a 50+ function library. Audit external API connections under Setup → Functions → Connections — expired tokens silently break dependent functions.

Common Failure Modes

Silent exceptions: a try/catch that swallows errors without logging or notifying makes debugging impossible. Always log caught exceptions with context. API rate limit exhaustion: a function that invokes external APIs in a loop without delay can burn the daily quota in minutes. Use batching and exponential backoff. Schema drift: a function that references Field_X breaks when Field_X is renamed or deleted — establish a “Custom Function Impact” check in your schema migration process.

What to do this week

Audit your function library for ownership and last-modified dates, deprecate any function with no recorded execution in the last 90 days, and add structured exception logging to your three highest-volume functions.

[object Object]
Share