In this article, we will explore the "Custom Function" features in Zoho CRM, along with detailed guidance on how users can deploy these scripts across different places within the Zoho CRM organization.
Custom Function
A Custom Function in Zoho CRM is a user-defined script that automates specific business processes, and it allows a user to extend Zoho CRM’s capabilities beyond default and standard features - such as creating/updating records, sending custom notifications, or custom integration with other applications - based on triggers like Workflow Rules, Blueprints, Schedulers, Buttons, etc. Custom Functions also help tailor the CRM to fit unique organizational needs and improve efficiency.
For example:
1. Whenever an incoming email is received from a Lead, set up a Workflow rule and use a custom function to create an Event(with dynamic information) automatically.
2. User can create a Task automatically when a high-value deal is created.
3. Send out all the attached documents automatically when a deal is reached at a certain stage (i.e., Deal Won).
4. Send data to an external system whenever a Lead is created/updated in Zoho CRM.
Deploy Custom Function in Zoho CRM
Centralized section to create Custom Function and deploy across various CRM features
We have a unified section in Zoho CRM where users can create custom functions and use them in multiple CRM features.
Functions can be created for any of the categories specified below:Button
- Automation
- Schedule
- Related List
- Standalone
- Signals
- Validation Rule
Navigate to Setup (⚙️) in Zoho CRM >> Developer Hub >> Functions >> My Functions >> New Function
Function Name -> Provide a name according to script usage.
Display -> Provide a name to identify the function while association/function list.
Description -> Provide script usage overview.
Category -> Select the CRM feature (mentioned above) where function needs to be associated.

Overview Recordings: Steps to Create Custom Functions Across Zoho CRM
To create Custom Function from "Developer Hub >> Functions" -> Screencast
To create Custom Function from various CRM automation features and Field mapping as Argument:
Approval Process with Custom Function -> Screencast
If the function requires fetching information based on fields present in any module and you want to add a field directly as an argument to the script, then we would recommend you to create the function directly from the required CRM automation feature (e.g., Workflow Action, Blueprint Action, etc.) to be able to associate fields as arguments from a specific module.
TIPS: How to Optimize the Code in Custom Function
It is essential to write code in an optimized way to ensure smooth execution and avoid potential errors when working with Custom Funciton in Zoho CRM. This also helps to enhance performance, maintainability, reduce unwanted API calls and a well-structured code with optimal logic.
Below are the best practices and tips which helps you optimise your code effectively:
Avoid Unnecessary Loops:
-> If you are using a Loop (i.e., for each{} ) in a script, then try to filter the records before it enters into the loop. You could also add an IF condition inside the 'For Loop' to filter records within the loop. Also, try using the built-in List / Map methods when possible in the script instead of having loops.
Minimize API Calls
-> Whenever a user uses any Zoho API (i.e. getRecords, insert, update, etc.) in a Deluge script, it makes a call to the server in order to fetch information from the authenticated user’s account and consumes an API credit. Excess API calls (or repeated API calls within Loop) may cause API usage to exceed the allowed limits.
-> Use Bulk CRM APIs, which make bulk actions (such as bulk read or bulk write) instead of looping through individual API calls.
Usage of Variables & Logging in Production
-> While writing the script, users can add info() logs to each variable to check the output for seamless functionality under the Console section within Zoho CRM IDE. After the complete code testing, we would suggest to remove or comment out logs and unused variables to make the script cleaner and easier to debug in the future. i.e., use conditional logging only for debugging purposes.
-> Ensure to use the meaningful variable names you define, which clearly reflect the data they store or the purpose they serve. This improves the readability of your script and makes debugging & collaboration significantly easier.
For example:
// ❌ Not recommended
- x = input.get("Account_Name");
- ar = Zoho.crm.getRecordbyID("Contacts", contactID);
// ✅ Recommended
- accountName = input.get("Account_Name");
- contact = Zoho.crm.getRecordbyID("Contacts", contactID);
Use Try-Catch Blocks
-> Use try-catch blocks to handle exceptions smartly without wrapping every line in a try. Log required error messages that help trace the exact problem with the line of code. Refer to the following Help Link to know the syntax & sample code. Optimize String & Date Handling
-> Use Deluge built-in convert methods such as toDate(), toString(), dateDiff(), toText() instead of custom logic. Refer to the Deluge Built-in Methods.
Use ifNull() to Prevent Errors
>
When you use get() method in Deluge function, try using ifNull() conditional statement to avoid any errors that say "get value is null" and execution stops immediately. When you associate a function with any automation (e.g, Workflow Rules) and if such error occured, it would stop function execution for the respective record. Help LINK to know more about ifNull statement.
Function Log - Success or Failures
-> Custom Function provides a "Failure" section to identify the errors which may occurs after you deployed in any of the automation feature (e.g., Workflow Rules, Blueprint, etc.). This section will list all the functions with name, entity(i.e. record), failure reason with exact failed time. This unified Failure section will help users to identify the exact problem in code and make the necessary adjustments.
Navigate to Setup (⚙️) in Zoho CRM >> Developer Hub >> Functions >> Failures
-> When a custom function is associated to any of the automation features, users can also see the complete Log of all function execution for any specific created function to track the executions (i.e. under My Functions >> 3 Dots >> Logs). This also help in a scenario where a function is executed via Workflow rule in CRM record(shows in timeline), however it didn't perform the intended actions/updates in record. In such scenario, users can check the output (info logs) & error of execution via function logs within Zoho CRM.
Ensure to use the Optimised Code to avoid facing limitations related to statement execution or execution time limits. Refer to Deluge Limitations to know more information.
Visit the following Help Link to understand Common Deluge Error Messages that may occur during Custom Function execution.