← Back to Library

Search by field, then update a related record

#

Look up a Contact by email to populate a lookup field on an Account. Note the Map() as the fifth param in searchRecords — required even when unused. The trigger syntax uses a set, not an array.

Create a CRM record

#

Standard createRecord call. Build your map beforehand, pass a connection name if calling cross-org. The trigger param controls whether workflows/blueprints fire on creation.

Error handling with email notification

#

Wrap risky operations in a try/catch, accumulate error state in a flag, then send a formatted diagnostic email at the end. Replace XXXXXXXX with the relevant response variable and fill in the to/subject fields.

Delete a CRM record via connector

#

zoho.crm.deleteRecord() exists but is unreliable. This invokeConnector approach is more consistent. Swap the module name as needed.

Copy attachments between records

#

Get attachment IDs from the related list, download each file via invokeurl, then re-attach to the target record. Fill in your connection name and swap the module/ID variables as needed.

Timeout / pause function

#

Deluge has no native sleep. The workaround: a Zoho Functions serverless Node.js function that waits N seconds, called via invokeurl. Deploy the JS as a standalone function, then call it from Deluge passing the desired delay. Wrap in try/catch — timeouts throw.

Timeout.js — the Node.js function

#

The serverless function that powers the timeout above. Deploy this in Zoho Functions as a Node.js function named "Timeout". It reads the seconds param and resolves after that delay.

Lead conversion via API

#

The native zoho.crm.convertLead() call is limited. This invokeurl approach hits the v7 API directly and gives you full control — pass an existing Contact ID to merge rather than create a new one. Requires a CRM connection with convert permissions.

Multi-select field — read and write

#

getRecordById returns multi-select values as a comma-delimited string. updateRecord expects a Deluge List. Use toList(",") to read, pass the list directly to update — do not use toString(";").

POST invokeurl with JSON body

#

Call any external REST API with a JSON body. The toString() on the params map is required — Deluge won't serialize it automatically. Set Content-Type in the headers map or the receiving API may reject it.

Add a note to a CRM record

#

Notes live in the Notes module. The Parent_Id is a map with the record's id, and se_module is the API name of the parent module. Swap module name and id as needed.

Parse zoho.crm.updateRecord response

#

zoho.crm.updateRecord returns the updated record directly — not a status wrapper. The presence of id in the response is the reliable success signal. A missing id or a code key indicates failure.

Multi-condition criteria string

#

Each condition must be wrapped in its own parentheses. AND/OR connect the groups with an outer pair around the whole expression. Missing parentheses cause silent failures — the search returns nothing without an error.

Date formatting and arithmetic

#

Deluge date arithmetic uses addDay(), addMonth() etc. on date objects. For API params and CRM field updates, format as yyyy-MM-dd. Comparing dates requires casting — two strings that look like dates don't compare numerically.

Get current user details

#

zoho.loginuserid gives the email of the user who triggered the function. zoho.adminuserid gives the org admin. To get the full user record (name, role, profile, etc.), search the Users module — it doesn't come back from the built-in variables.

← Back to Library
Anyone who has never made a mistake has never tried anything new.
— Albert Einstein