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
How do you print a refund check to customer?
Maybe this is a dumb question, but how does anyone print a refund check to a customer? We cant find anywhere to either just print a check and pick a customer, or where to do so from a credit note.
Notebook
I have purchased the monthly pro subscription of Notebook. But it does not support my XP-Pen to write something in it. So it is not useful to me. Hence I am requesting you to help me to discontinue this subscription.
Domain Mapping & Image Publishing Issues on Zoho Sites
Hello, I am facing two issues with my Zoho Sites account: 1. Images not visible after publishing. 2. Domain mapping error: "Domain already exists". I am a paid customer. Please connect me with Live Chat Support or Zoho Assist so I can show my issue
Prevent duplicate with custom fields?
I was wondering something about custom field/custom modules in Zoho Desk. For some reason you can make a custom field mandatory but not unique? For example, if I create a custom module to manage equipment and renewal and make a field serial number no
Round robin
Hi, I'm trying to set up a round robin to automatically distribute tickets between agents in my team but only those tickets that are not otherwise distributed by other workflows or direct assignments. Is that possible and if so which criteria should I
"Is Zoho CRM customer" vs "Is linked with Zoho CRM"
Recently while building a Flow, I was setting up a Decision action following a Zoho Invoice Fetch record action. There were 2 choices that I had not seen as something I could manually action in Zoho Invoice: "Is Zoho CRM customer" and "Is linked with
Two currencies
More and more I am finding that internattional payments' fees are unpredictable. I would like, on my invoices that are in a foreign currency (eg. USD$ or EUR€) for there to be a GBP£ TOTAL display alongside the invoice's currency total. This would make
Automatic Matching from Bank Statements / Feeds
Is it possible to have transactions from a feed or bank statement automatically match when certain criteria are met? My use case, which is pretty broadly applicable, is e-commerce transactions for merchant services accounts (clearing accounts). In these
Generate leads from instagram
hello i have question. If connect instagram using zoho social, it is possible to get lead from instagram? example if someone send me direct message or comment on my post and then they generate to lead
Zoho PDF editor has a lot of issues.
Zoho PDF editor needs a lot of work. It hangs and glitches a lot. Deletes annotations and clearings randomly.
Where is the desktop app for Zoho Projects???
As a project manager, I need a desktop app for the projects I manage. Yes, there's the web app, which is AWESOME for cross browser and platform compatibility... but I need a real desktop app for Projects that allow me to enter offline information where
How to Automate Monthly PDF Reports with Filters in Zoho Creator
Hi everyone, I’m trying to build an automated monthly reporting process in Zoho Creator and would appreciate suggestions or best practices from anyone who has done something similar. What I’m trying to do: I have a form called New_Customer with fields
Feedback: Streamlining Note Management in Zoho Notebook
Dear Team/Support, I would like to share some feedback regarding the note management system that could help improve usability and accessibility for users like myself. Notebook 1 (screenshot attached): Currently, the system does not allow selecting and
showing Limit exceeded
Good afternoon...trust you're good. I've been having issues working with but it's not responding. it's showing Limit exceeded, sorry it seems like too many people are working on the sheet right now please try again later. meanwhile no one is working on
Converting Sales Order to Invoice via API; Problem with decimal places tax
We are having problems converting a Sales Order to an Invoice via API Call. The cause of the issue is, that the Tax value in a Sales Order is sometimes calculated with up to 16 decimal places (e.g. 0.8730000000000001). The max decimal places allowed in
Sorting columns in Zoho Projects
Hi, In project management best practice, sorting columns (ascending, descending) is an important tool. Sorting dates to see the order of tasks starting, sorting on priority or even on planned hours is a must for an efficient project control. Currently,
Business Continuity - Disaster Recovery
I know about the Zoho CRM backup .zip files, however, this doesn't include any of the infrastructure with like custom fields or custom modules. I am curious on what everyone has in place for a true backup or what your plan is if your Zoho instance were
Upload API
I'm trying to use the Upload API to upload some images and attach them to comments (https://desk.zoho.com/DeskAPIDocument#Uploads#Uploads_Uploadfile) - however I can only ever get a 401 or bad request back. I'm using an OAuth token with the Desk.tickets.ALL
Losing description after merging tickets
Hello, We merge tickets when they are about the same topic from the same client. It happens sometimes. We recently noticed that after the merger only the description from the master ticket is left in a thread. And the slave-ticket description is erased.
Option to Empty Entire Mailbox or Folder in Zoho Mail
Hello Zoho Mail Team, How are you? We would like to request an enhancement to Zoho Mail that would allow administrators and users to quickly clear out entire folders or mailboxes, including shared mailboxes. Current Limitation: At present, Zoho Mail only
update linked contacts when update happens in account
Hi, I have a custom field called Licence in the Accounts module. When someone buys a licence, I’d like to update a custom field in the related Contacts. How can I achieve this? I noticed that workflows triggered on Accounts only allow me to update fields
Problem Management Module
I am looking for a Problem Management module within Zoho Desk. I saw in some training videos that this is available, and some even provided an annual price for it. I want an official confirmation on whether this is indeed available. This is not a particularly
Deluge sendmail in Zoho Desk schedule can't send email from a verified email address
I am trying to add a scheduled action with ZDesk using a Deluge function that sends a weekly email to specific ticket client contacts I've already verified the email address for use in ZDesk, but sendmail won't allow it in its "from:" clause. I've attached
Unable to explore desk.zoho.com
Greetings, I have an account with zoho which already has a survey subscription. I would like to explore desk.zoho.com, but when I visit it while logged in (https://desk.zoho.com/agent?action=CreatePortal) I just get a blank page. I have tried different
Offline support for mobile app
Accessing your files and folders from your mobile devices is now quicker and simpler, thanks to the power of offline support. Whether on an Android or iOS device, you can use the Offline function to save files and folders, so you can review them even
Zoho Desk KB article embedded on another site.
We embed KB articles from Zoho Desk on another site (our application). When opening the article in a new tab, there is no issue, but if we choose lightbox, we are getting an error "To protect your security, help.ourdomain.com will not allow Firefox to
Transitioning to API Credits in Zoho Desk
At Zoho Desk, we’re always looking for ways to help keep your business operations running smoothly. This includes empowering teams that rely on APIs for essential integrations, functions and extensions. We’ve reimagined how API usage is measured to give
List of packaged components and if they are upgradable
Hello, In reference to the article Components and Packaging in Zoho Vertical Studio, can you provide an overview of what these are. Can you also please provide a list of of components that are considered Packaged and also whether they are Upgradable?
Does Attari Messaging app have Bot option and APIB
Hi, Does Attari also have Bot and API as we use in WhatsApp??
How to add application logo
I'm creating an application which i do not want it to show my organization logo so i have changed the setting but i cannot find where to upload/select the logo i wish to use for my application. I have seen something online about using Deluge and writing
Introducing Keyboard Shortcuts for Zoho CRM
Dear Customers, We're happy to introduce keyboard shortcuts for Zoho CRM features! Until now, you might have been navigating to modules manually using the mouse, and at times, it could be tedious, especially when you had to search for specific modules
Empowered Custom Views: Cross-Module Criteria Now Supported in Zoho CRM
Hello everyone, We’re excited to introduce cross-module criteria support in custom views! Custom views provide personalized perspectives on your data and that you can save for future use. You can share these views with all users or specific individuals
Send Automated WhatsApp Messages and Leverage the Improved WhatsApp Templates
Greetings, I hope all of you are doing well. We're excited to announce a major upgrade to Bigin's WhatsApp integration that brings more flexibility, interactivity, and automation to your customer messaging. WhatsApp message automation You can now use
Verifying Zoho Mail Functionality After Switching DNS from Cloudflare to Hosting Provider
I initially configured my domain's (https://roblaxmod.com/) email with Zoho Mail while using Cloudflare to manage my DNS records (MX, SPF, etc.). All services were working correctly. Recently, I have removed my site from Cloudflare and switched my domain's
Zoho Analytics Regex Support
When can we expect full regex support in Zoho Analytics SQL such as REGEXP_REPLACE? Sometimes I need to clean the data and using regex functions is the easiest way to achieve this.
Change of Blog Author
Hi, I am creating the blog post on behalf of my colleague. When I publish the post, it is showing my name as author of the post which is not intended and needs to be changed to my colleague's name. How can I change the name of the author in the blogs?? Thanks, Ramanan
Show Attachments in the customer portal
Hi, is it possible to show the Attachments list in the portal for the particular module? Bests.
Zoho CRM Formula - Current Time minus Date/Time field
Hello, I am trying to prevent duplicate emails going to clients when more than 1 deal is being updated. To do this, I would like to create a formula to identify if a date/time field is >= 2 hours ago. Can someone please help me write this formula? Example:
Does Zoho Docs have a Line Number function ?
Hi, when collaborating with coding tasks, I need an online real time share document that shows line numbers. Does Zoho's docs offer this feature ? If yes, how can I show them ? Regards, Frank
Feature Request - Insert URL Links in Folders
I would love to see the ability to create simple URL links with titles in WorkDrive. or perhaps a WorkDrive extension to allow it. Example use case: A team is working on a project and there is project folder in WordDrive. The team uses LucidChart to create
Next Page