Season's greetings to our coding enthusiasts!
Let us code our way into the festive spirit with another insightful post in our
Kaizen series!
In this post, we will explore the process of creating a custom button using functions on the records' detail page. This enables the deletion of all associated child records when the current record is deleted. To fulfill this requirement, we will leverage APIs like
COQL API,
Records API, and
Mass Delete API.
Currently, Zoho CRM provides the delete action exclusively for a specific related list modules when the parent record is deleted. Here are the specifics of ZOHO CRM's default support for deleting related list modules:
Record Module | Related List Module |
Leads
| Activities, Visits and Email Drafts |
Contacts | Activities, Visits, Appointments and Email Drafts |
Accounts | Activities, Contacts, Deals, Quotes, Sales Orders, Invoices, Cases, Appointments and Email Drafts |
Deals | Activities, Cases, Competitors and Email Drafts |
Campaigns | Activities, Email Drafts and Child Campaigns |
Cases | Activities and Email Drafts |
Products | Activities, Solutions, Cases and Email Drafts |
Vendors | Activities and Email Drafts |
Quotes | Activities and Email Drafts |
Sales Orders | Activities and Email Drafts |
Purchase Orders | Activities and Email Drafts |
Invoices | Activities and Email Drafts |
Services | Appointments and Email Drafts |
Custom | Activities and Email Drafts |
Perform Mass Delete Across Modules
Assume that you are the Manager of Zylker, an educational institution utilizing ZOHO CRM for customer relationship management. You have implemented custom modules, namely Training Program and Participants in your organization.
Now, you aim to streamline record management by creating a custom button on the Training Program module's records detail page. On triggering, this button should delete all associated participants of a specific program along with the program itself.
Let us guide you through the step-by-step process of fulfilling this requirement using ZOHO CRM functions.
Prerequisites
Achieving this requirement is versatile, applicable to both records with a single child module as well as records with multiple child modules.
A lookup field serves to establish a connection between two modules, designating the module where the lookup field is employed as the child module. The module that the lookup field points to is referred to as the parent module.
To keep it simple, let us consider Participants as the child module with a lookup relationship to the Training Program parent module.
Creating a Custom Button
Step 1: Begin by navigating to Setup > Customization > Modules and Fields > Training Program > Links and Buttons > New Button within your ZOHO CRM interface.
Step 2: Provide a name and description for the button. Next, select the Details Page as the designated location for the button from the drop-down menu.
Refer to
this document to learn more on creating and using custom buttons.
Step 3: Configure the button's action by selecting Writing Function from the menu.

Step 4: Fill in the basic details for creating a new function.
Step 5: After clicking the create button, you will be directed to an editor interface, as depicted in this image.

You have to code your function logic in this editor and click the Save button on the top right corner.
For the scenario discussed, we have attached the function code in a zip file with this post. Download and explore the code to gain hands-on experience in this use case.
Step 6: Next, you will be redirected to the Links and Buttons page, where you need to configure the visibility of the button based on profiles. Afterward, click on the Save button to confirm your settings.
Flow of the function
The function should initially make a COQL API call to retrieve the participant records that correspond to the record ID of the training program from which the button is triggered. This API can fetch up to 2000 related child records in a single API call.
queryMap = Map(); queryMap.put("select_query","select id from Participants where Training_Program =" + id + "Limit 2000"); response = invokeurl [ type :POST parameters:queryMap.toString() connection:"crm_oauth_connection" ]; |
Here,
connections are used to make ZOHO CRM API calls. To get the current record ID, you have to configure it in function arguments.
Click Edit Arguments from the top of the page and associate the Training Program ID as shown in this image.

Before proceeding to the next step, it's crucial to be aware of the following constraints associated with the APIs:
- COQL API: It can retrieve a maximum of 2000 records per API call.
- Delete Records API: It has the capability to delete up to 100 records in a single API call.
- Mass Delete Records API: By utilizing record IDs, it can delete a maximum of 500 records per API call.
Given these constraints, the following logic has been devised to address our specified requirement:
---> If the participant count is 0, the system should proceed to delete the current record exclusively.
---> Incases where the record count is below 100, the Delete Record API must be employed to eliminate records from the Participants module.
---> If the participant count exceeds 100, the Mass Delete Records API should be used for deleting records within the child module. For scenarios where more than 500 records need deletion, it is necessary to execute this in a loop for four iterations with each deleting 500 records.
Let us execute this logic in Deluge script,
if(!isNull(response)) { response = response.toMap(); count = response.getJSON("info").get("count").toNumber(); has_more = response.getJSON("info").get("more_records"); id_list = List(); itr_list = {0,1,2,3}; response = response.getJSON("data"); result = List(); if(count > 0) { for each item in response { id_list.add(item.getJSON("id")); } if(count > 100) { end = 0; start = 0; for each itr in itr_list { if(count / 500 - itr > 0) { idMap = Map(); if(count - end > 500) { end = end + 500; } else { end = count; } idMap.put("ids",id_list.subList(start,end)); response = invokeurl [ type :POST parameters:idMap.toString() connection:"crm_oauth_connection" ]; start = end; } } } else { response = invokeurl [ type :DELETE connection:"crm_oauth_connection" ]; } } } |
Now, let us address the scenario of a training program with over 2000 participants. Following the logic outlined above, our custom button will handle the deletion of only 2000 records.
To manage this, after successfully deleting the initial 2000 records, the record from the Training Program module should not be deleted. Here, we have to configure a pop-up message signaling that additional records require deletion. To proceed, users must click the same button to eliminate the remaining records along with the current one.
After deleting all records from the child modules, the custom button will proceed to remove the current Training Program record, as shown in the following Deluge code.
if(isNull(response) || !has_more) { response = invokeurl [ type :DELETE connection:"crm_oauth_connection" ]; return "Deleted Successfully"; } return "Over 2000 related records were detected. Click 'Cascade Delete' again to delete the remaining and this training program. "; |
Let us now check our custom button from the details page of the Training Programs module.
To prevent additional clicks for deleting the remaining records, we will circle back to you on next Friday with a solution that incorporates the looping mechanism.
We have also brought you a wave of innovation and enhanced features in our
V6 APIs. Take a look at them and empower your coding journey with us.
If you have any queries, feel free to drop them in the comments section below or reach out to us directly at
support@zohocrm.com. We eagerly await your thoughts and feedback on this!
Cheers to a productive and joyful season!
Recent Topics
Accessing Zoho Forms
Hi all, We're having trouble giving me access to our company's Zoho Forms account. I can log in to a Forms account that I can see was set up a year ago, but can't see any shared forms. I can log into Zoho CRM and see our company information there without
Archiving Contacts
How do I archive a list of contacts, or individual contacts?
Cost of good field
Is there a way we can have cost of good sold as a field added to the back end of the invoicing procedure and available in reports?
How to add image to items list in Invoice or Estimate?
Hello! I have just started using Zoho Invoice to create estimates and, possibly to switch from our current CRM/ERP Vendor to Zoho. I have a small company that is installing CCTV systems and Alarm systems. My question is, can I add images of my "items" to item list in Zoho Invoice and Estimates and their description? I would like to show my clients the image of items in our estimates so they can decide if they like these items. And I tell you, often they choose more expensive products just because
Issue with the Permission to Zoho Form
I am getting an error by signing in to zoho form as it is stated that i don't have permission to access this is admin account
CRM templates
Hello everyone, In my company we use Zoho campaigns where we set up all newsletters and we use Zoho CRM for transactional emails. I have created some templates in Zoho campaigns but from my understanding i cannot use those in Zoho CRM, right?
Meet Canvas' Grid component: Your easiest way to build responsive record templates
Visual design can be exciting—until you're knee-deep in the details. Whether it's aligning text boxes to prevent overlaps, fixing negative space, or simply making sure the right data stands out, just ironing out inconsistencies takes a lot of moving parts.
Addin Support in Zoho Sheet
Is there any addin support available in zoho sheet as like google marketplace to enhance productivity by connecting with other apps, providing AI data analysis, streamlining business processes, and more?
Where to integrate Price Book and Product List Price
Hello, We sync zoho crm all modules with all data to zoho analytics. In zoho crm, we have "Price Books" and "Products" modules, where each product is assigned to a few price books with different list prices. From zoho crm, I am able to export a dataset
Pending Sales Order Reports
Pending sale order report is available for any single customer, Individual report is available after 3-4 clicks but consolidated list is needed to know the status each item. please help me.
Zoho Mail SMTP IP addresses
We are using Zoho Mail and needs to whitelist IP for some redirections from your service to another e-mails. You can provide IP address list for Zohomail SMTP servers?
Migrate Your Notes from OneNote to Zoho Notebook Today
Greetings Notebook Users, We’re excited to introduce a powerful new feature that lets you migrate your notes from Microsoft OneNote to Zoho Notebook—making your transition faster and more seamless than ever. ✨ What’s New One-click migration: Easily import
Zoho Campaigns - Why do contacts have owners?
When searching for contacts in Zoho Campaigns I am sometimes caught out when I don't select the filter option "Inactive users". So it appears that I have some contacts missing, until I realise that I need to select that option. Campaigns Support have
One Contact with Multiple Accounts with Portal enabled
I have a contact that manages different accounts, so he needs to see the invoices of all the companies he manage in Portal but I found it not possible.. any idea? I tried to set different customers with the same email contact with the portal enabled and
End Date in Zoho Bookings
When I give my appointments a 30 minutes time I would expect the software not to even show the End Time. But it actually makes the user pick an End Time. Did I just miss a setting?
email forwarding not working
Your email forwarding service does not work. I received the confirmation email and completed the confirmation, after that nothing and nothing since no matter what I have tried. Shame as everything else was smooth. I spose it's harder to run one of these web based internet mail services than you guys thought!!! can you fix the email forwarding asap PLEASE!
Google Ads Conversions Not Being Tracked in Zoho CRM
We have 3 different conversions created in our Google Ads Account. Only one of the 3 conversion types is tracking in Zoho CRM. Our forms are Elementor Forms that are mapped into Zoho CRM. It apprears to me that all leads are showing up in Zoho CRM, but
Enable Locations for Expense
Hi, please enable Locations (ex Branches) for Zoho Expense so that there is consistency between this app and Zoho Books. Thanks in advance.
Currency abbreviations
Hello, Im stuck, and need help. I need the currency fields for example, opportunity value, or total revenue, to be abbreviated, lets say for 1,000 - 1K, 1,000,000 - 1M, and so on, how should I do this?
in the Zoho Creator i have File Upload field get the file on submission of the form Get the File and upload to Zoho Books
in the Zoho Creator i have File Upload field get the file on submission of the form Get the File and upload to Zoho Books . how I get the file From zoho creator and upload to Zoho Books . using Api response = invokeUrl [ url: "https://www.zohoapis.com/creator/v2.1/data/hh/l130/report/All_Customer_Payments/"+input.ID
Generate a link for Zoho Sign we can copy and use in a separate email
Please consider adding functionality that would all a user to copy a reminder link so that we can include it in a personalized email instead of sending a Zoho reminder. Or, allow us to customize the reminder email. Use Case: We have clients we need to
Syntax for URLs in HTML Snippets
What are some best practices for inserting a URL in an HTML snippet? I've looked at Zoho Help articles on navigation-based and functional-based URLs, but I'm still unclear on how to incorporate them in an HTML snippet. For example, 1. How do I link to
Rate Limiting in Zoho Flow (OpenAI API)
Hi Everyone, We are facing some issues when using Zoho Flow as we have a deluge script running which is making external calls to OpenAI endpoint. Sometimes the response takes more than 30 seconds meaning the script will timeout. We want to implement a
Placing a condition before converting the LEAD
Hi, I need some assistance with Lead conversion. I need to place certain conditions before allowing the user to convert the lead. For example: up until the certain status's doesn't equal "green" don't allow to convert lead. I tried creating this using
it is possible to open a widget via deluge script function
I have one function that is workflow action I call my fucntion I need to call the internal widget it is possible to open or it have to please tell me the solution
Creator - Portal Custom Domain
I will pay $100 in crypto to anyone who can actually get my Creator Custom Domain to function (actually tell me how you got yours to). Domain verifies, Nothing. I've been fighting it a week, multiple chats to customer service. Clearly I'm doing something wrong. Some datapoints Domain name itself unimportant, can be a string of numbers. I need to know what registrars are working for you because GoDaddy does NOT. Do I need hosting? I've tried both ways and nothing works. I pushed through Cloudflare
steps and options to change Domain DNS/Nameservers settings
Please share the options or steps to change Domain DNS/Nameservers settings
Employees in Leave Policy exceptions
In the Leave Policies we should be able to add specific employees to the exception list So it will be like All Employees except A,B,C in the exception list, currently we can only add departments etc
How I set default email addresses for Sales Orders and Invoices
I have customers that have different departments that handle Sales Orders and Invoices. How can i set a default email for Sales Orders that's different than the default email for Invoices? Is there a way I can automate this using the Contact Persons Departments
Modular Permission Levels
We need more modular Permissions per module in Books we have 2 use cases that are creating problems We need per module export permission we have a use case where users should be able to view the sales orders but not export it, but they can export other
Kaizen #157: Flyouts in Client Script
Hello everyone! Welcome back to another exciting edition of our Kaizen series, where we explore fresh insights and innovative ideas to help you discover more and expand your knowledge!In this post, we'll walk through how to display Flyouts in Client Script
How get stock name from other column ?
How get stock name from other column ? e.g. =STOCK(C12;"price") where C12 is the code of the stock
Adding a developer for editing the client application with a single user license
Hi, I want to know that I as a developer I developed one application and handed over to the customer who is using the application on a single user license. Now after6 months customer came back to me and needs some changes in the application. Can a customer
Download an email template in html code
Hello everyone, I have created an email template and I want to download it as html. How can i do that? I know you can do it via the campaigns-first create a campaign add the template and download it as html from there. But what if i don't want to create
Attachment is not included in e-mails sent through Wordpress
I have a Wordpress site with Zeptomail Wordpress plugin installed and configured. E-mails are sent ok through Zeptomail but without the included attachment (.pdf file) Zeptomail is used to send tickets to customers through Zeptomail. E-Mails are generated
Upcoming Changes to the Timesheet Module
The Timesheet module will undergo a significant change in the upcoming weeks. To start with, we will be renaming Timesheet module to Time Logs. This update will go live early next week. Significance of this change This change will facilitate our next
Best way to schedule bill payments to vendors
I've integrated Forte so that I can convert POs to bills and make payments to my vendors all through Books. Is there a way to schedule the bill payments as some of my vendors are net 30, net 60 and even net 90 days. If I can't get this to work, I'll have
Cant update image field after uploading image to ZFS
Hello i recently made an application in zoho creator for customer service where customers could upload their complaints every field has been mapped from creator into crm and works fine except for the image upload field i have tried every method to make
Billing Management: #4 Negate Risk Free with Advances
In the last post, we explored how unbilled charges accumulate before being invoiced. But what happens when businesses need money before service begins? Picture this: A construction company takes on a $500,000 commercial building project expected to last
Is there an equivalent to the radius search in RECRUIT available in the CRM
We have a need to find all Leads and/or Contacts within a given radius of a given location (most likely postcode) but also possibly an address. I was wondering whether anyone has found a way to achieve this in the CRM much as the radius search in RECRUIT
Next Page