Kaizen #118 - Mass Delete Records Across Modules (Part II)

Kaizen #118 - Mass Delete Records Across Modules (Part II)

Hey there! Welcome back to yet another insightful post in our Kaizen series!

Picking up the thread from our last post, let's explore how to automate the process of mass deleting child records directly from the parent record's details page. This approach eliminates the need to click the Cascade Delete button repeatedly, when dealing with parent records containing over 2000 child records.

Prevent Additional Clicks to Delete 2000+ Records

Step 1 - Get the Child Record Count

Make a COQL API call in the function and get the total number of child records associated with the specific parent record.

queryMap = Map();
queryMap.put("select_query","select COUNT(id) from Participants where Training_Program=" + id);
response = invokeurl
[
type :POST
parameters:queryMap.toString()
connection:"crm_oauth_connection"
];

Step 2 - Loops and Deluge Script

The count of child records obtained from the preceding step's response will determine the necessary iterations for executing the action. 

---> To ascertain the number of iterations, divide the total record count by 2000, and consider the nearest largest integer as the iteration count.
---> Subsequently, the entire function from the earlier post will undergo looping. Whenever the button is clicked, the placeholders (whitespaces) will be filled in accordance with the record count division, ensuring seamless delete process.
---> If there are no child records available, then it should skip the loop and delete the parent record alone. 

iterations = (response.getJSON("data").get(0).get("COUNT(id)") / 2000).ceil();
no_records_flag = false;
if(iterations == 0)
{
no_records_flag = true;
iterations = 1;
}
iterationString = "".leftPad(iterations).replaceAll(" ",",").toList().subList(0,iterations);
for each iteration in iterationString
{
if(!no_records_flag)
Handle the function code from previous post here.
}

Let us now check this from the details page of a Training Program with 7000 participants. 


Looping Constraints in Functions

The maximum file size for the function code is 2 mb and less than 1 mb is preferable for the seamless execution, which translates to approximately 6,500 lines of code. Furthermore, the function's maximum execution time is capped at 5 minutes. Any function surpassing this limit will be automatically terminated, accompanied by the error message: The limit of time has reached its maximum 300000 (milliseconds).

We trust you found this post both beneficial and informative!

Your thoughts and perspectives matter to us. If there is a topic you would like us to delve into or if you have any questions, please feel free to drop a comment below or send us an email at support@zohocrm.com.

Keep an eye out for future posts packed with similar content!

Cheers!


Additional Reading

Deluge Script
  • Number Functions in Deluge - ceil 
  • Text Functions - leftpad
Query API






    Access your files securely from anywhere







                            Zoho Developer Community




                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts



                                                            • Sticky Posts

                                                            • Kaizen #217 - Actions APIs : Tasks

                                                              Welcome to another week of Kaizen! In last week's post we discussed Email Notifications APIs which act as the link between your Workflow automations and you. We have discussed how Zylker Cloud Services uses Email Notifications API in their custom dashboard.
                                                            • Kaizen #216 - Actions APIs : Email Notifications

                                                              Welcome to another week of Kaizen! For the last three weeks, we have been discussing Zylker's workflows. We successfully updated a dormant workflow, built a new one from the ground up and more. But our work is not finished—these automated processes are
                                                            • Kaizen #152 - Client Script Support for the new Canvas Record Forms

                                                              Hello everyone! Have you ever wanted to trigger actions on click of a canvas button, icon, or text mandatory forms in Create/Edit and Clone Pages? Have you ever wanted to control how elements behave on the new Canvas Record Forms? This can be achieved
                                                            • Kaizen #142: How to Navigate to Another Page in Zoho CRM using Client Script

                                                              Hello everyone! Welcome back to another exciting Kaizen post. In this post, let us see how you can you navigate to different Pages using Client Script. In this Kaizen post, Need to Navigate to different Pages Client Script ZDKs related to navigation A.
                                                            • Kaizen #210 - Answering your Questions | Event Management System using ZDK CLI

                                                              Hello Everyone, Welcome back to yet another post in the Kaizen Series! As you already may know, for the Kaizen #200 milestone, we asked for your feedback and many of you suggested topics for us to discuss. We have been writing on these topics over the


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner







                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources

                                                                                              Zoho Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ




                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方







                                                                                                              • Recent Topics

                                                                                                              • Nouveauté dans Zoho Writer - Création de documents et de modèles assistée par l'IA

                                                                                                                Zia, l’assistant IA de Zoho Writer, soutient les utilisateurs dans l’amélioration de leur écriture et la création de contenus : correction orthographique et grammaticale en temps réel, suggestions adaptées au contexte, détection du plagiat, révisions
                                                                                                              • Session Expired

                                                                                                                I constantly get "Session Expired" and need to relogin or close and open the application again. This gets really frustrating during the day. Is this something that can be solved? This really makes me want to leave the app as it is no go to need to reopen
                                                                                                              • Disable Buttons for Users with Profiles without permission

                                                                                                                Hey, I've noticed that users without permission of setting up things in the marketplace, can still see the icon: On a click, you see this: It would be way better, if they couldn't see this menu icon at all. (Aside from the fact that it completely misplaced
                                                                                                              • Mapping a new Ticket in Zoho Desk to an Account or Deal in Zoho CRM manually

                                                                                                                Is there any way for me to map an existing ticket in Zoho desk to an account or Deal within Zoho CRM? Sometimes people use different email to put in a ticket than the one that we have in the CRM, but it's still the same person. We would like to be able
                                                                                                              • Zoho Analytics - Make text clickable in underlying data

                                                                                                                Hi Community, I have a simple sales report based on a Invoice query table. I have included a link on to each invoice on the table and sent the Invoice number URL to the link. This works find in the query table, but when I click underlying data on the
                                                                                                              • Credit Management: #5 Advanced Refund Policy

                                                                                                                You're subscribed to a well-known SaaS design tool. You've used it to manage your team's projects, create marketing visuals, brochures, and so on. But your needs change over time. Your company may switch to another tool or hire an in-house designer who
                                                                                                              • Exported Slide Image Lacks Portion of the Background Image

                                                                                                                This does not always happen, but when I export (or "download") the rendered image of a slide, it sometimes lacks a portion of the background image. I created a sample slide deck to demonstrate it and shared it with the admins. It is also publicly available
                                                                                                              • Effective Inbox Organization: Folders vs Tags in Zoho Mail?

                                                                                                                I'm exploring the best ways to organize a busy inbox, especially when managing multiple clients or project using Zoho Mail. I’d love to know what works best for others: 1. Do you prefer **folders** (possibly with sub-folders) for each client or project?
                                                                                                              • Piss poor service in Support in Domains and email

                                                                                                                Srijith Narayanan B contacted me today. Very pleasant fellow. Just didn't want to tell him how bad your support service is. You help the person, but you leave before we can finish the next stage. Which causes a lot of frustration. It's been 8 days now
                                                                                                              • Zoho Mail android app update: Block & reject future emails, Report phishing, Spam alerts, Suspicious URL detection

                                                                                                                Hello everyone! In the most recent Zoho Mail Android app update, we have brought in support for the following features: Block & reject future emails Report Phishing Spam alerts in the mail details screen. Suspicious URL detection. Block & reject future
                                                                                                              • Zohomail does not support additional fields in mailto links

                                                                                                                Hello, I set up Zohomail as default composer in Firefox according to manual here: https://www.zoho.com/mail/help/defaultcomposer.html#alink2 Later, I wanted to use this functionality to answer in a Linux mailing list thread using mailto link: mailto:xxxxx@kernel.org?In-Reply-To=%3C727o0521-q24p-s0qq-66n0-sn436rpqqr1p@example.com%3E&Cc=xxxxx%example.org&Subject=Re%3A%20%5BPATCH%20v2%28%29
                                                                                                              • Email address for forwarding is not saving and there's no confirmation ema

                                                                                                                Steps to reproduce: 1. Enter my forward email in the email forward section of the account 2. Click save 3. See a notification stating saved successfully 4. Refresh the page, no forward email is saved 5. No email confirmation received at the forwarding
                                                                                                              • This domain is not allowed to add in Zoho. Please contact support-as@zohocorp.com for further details

                                                                                                                This is the error i keep getting when trying to use my Zoho Domain Mail. This domain is not allowed to add in Zoho. Please contact support-as@zohocorp.com for further details Find attached. I hope this can be resolved very quickly so i can go on and make
                                                                                                              • Auto CC - Moving Departments

                                                                                                                We have Auto CC e-mail replies to your support mailbox enabled. We have two departments: Helpdesk (helpdesk@domain.com) Delivery (delivery@domain.com) If we create a Helpdesk ticket, and reply, replies are CC'd to helpdesk@domain.com (OK) We then move
                                                                                                              • Unable to see free plan option

                                                                                                                Hello Zoho Support Team, I hope you are doing well. I am trying to sign up for Zoho Mail, but I am unable to see the option for the free plan. Could you please guide me on how I can access or activate the free plan? Thank you for your assistance.
                                                                                                              • Sorten the domain of zoho mail ids

                                                                                                                I recently created zoho mail id and am quite excited with the features. But one issue ig nobody wanna type this big zohoaccounts.com I mean silly bold Suggestion zmail.com (sound gmail) (attraction) or some genz words looks cool
                                                                                                              • Weekly Tips : Customize your Zoho Mail Notifications

                                                                                                                In a professional context, email communication remains one of the most crucial channels for staying connected and managing workflows. Keeping track of your emails, task updates, or important announcements can be overwhelming—especially if you are juggling
                                                                                                              • The attendees will now be redirected to the landing webpage when they exit the webinar, set by the organizer.

                                                                                                                Hello All, In the latest version of the Zoho Meeting iOS mobile app (v1.3.16), we have brought in the below enhancements:   Post Webinar Re-direction Revamped exit UI for Webinar Post Webinar Re-direction:  The attendees will now be redirected to the
                                                                                                              • 550-5.1.1 The email account that you tried to reach does not exist

                                                                                                                Hi, I made sure my domain, SPF, MX records, and DKIM are all verified. I've entered the information correctly in cPanel and Email Routing is set to Remote Mail Exchanger. I am able to send, but unable to receive emails. When I sent a test reply to it, I get the following error: The response was: 550-5.1.1 The email account that you tried to reach does not exist. Please try 550-5.1.1 double-checking the recipient's email address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1 https://support.google.com/mail/?p=NoSuchUser
                                                                                                              • Download API file contents from browser

                                                                                                                Hi Team - is there something being planned to be able to trigger file downloads from the browser via a deluge script? i.e. retrieve a file via API, trigger the file download directly from the browser. Or... using the convertToPdf function (https://www.zoho.com/deluge/help/functions/file/convert-to-pdf.html)
                                                                                                              • When using "locations" in zoho books, can you keep the two locations totally separate from each other?

                                                                                                                I am looking to add a location but I don't want to intermingle the banking or other accounts. I want that to be like two separate independent branches that use different banking accounts, accounts payable, and accounts receivable. The people who are in
                                                                                                              • Adding a Channel to SalesIQ

                                                                                                                I have a client that currently uses Zoho CRM and Zoho Desk. They would like a live chat to place on their website that has a mobile app and chat bots (something like SalesIQ). However, they would also like to have all this work over SMS as well. Does the SalesIQ API allow this? Can I add visitors without them being a visitor on a website? Thanks! Bryan Redeagle
                                                                                                              • Zoho Flow Needs to Embrace AI Agent Protocols to Stay Competitive

                                                                                                                Zoho Flow has long been a reliable platform for automating workflows and integrating various applications. However, in the rapidly evolving landscape of AI-driven automation, it risks falling behind competitors like n8n, which are pioneering advancements
                                                                                                              • Important Features Missing

                                                                                                                Hey all I love linkthread, but i am missing some important features. I want to be able to include my Google Tag Manager. I have all the important stuff in my GTM Container: Facebook Pixel, LinkIn Pixel, Zoho Pagesense and so on. So i am able to do retargeting
                                                                                                              • Zoho SignForms: Prefill parameters with spaces render as “+” in the document (even when using %20)

                                                                                                                Hello Zoho Sign team, we are using SignForms with prefill parameters passed via URL. Spaces in parameter values are being rendered as “+” in the finalized document—even when we URL-encode spaces as %20. This is critical for us because we prefill addresses
                                                                                                              • Currency selector (based on variable) usage in comparsion

                                                                                                                Hi, I've developed a currency selector based on the following topic, and it's working well in pivot tables and charts: https://help.zoho.com/portal/en/community/topic/how-can-i-allow-my-users-to-choose-a-currency-for-the-dashboard I also have a comparison
                                                                                                              • Customize Column in Projects - Default View for Template?

                                                                                                                Is there a way to have the columns you'd like to see added to a template? I want my customized columns to show up every single time I create a project from that template. It appears I can customize them in the template but when I create the project they do not transfer over.  Template: See below how the columns in order are : Task, Owner, Status, Assigned, Website URL, Blog H1..etc. When I create a project from that same template it comes out as: Task, Owner, Status, Tags, Start Date, End Date, etc
                                                                                                              • Ask the Experts 24: Analytics, data administration, and mobile experience with Zoho Desk

                                                                                                                Hello Everyone! Welcome back to the Ask the Experts(ATE) series! We were so focused on our Autumn 2025 release that we didn't host an ATE session last month. In this month's ATE, we'd like to expand our areas for discussion: we'd like to listen to your
                                                                                                              • Multi-Page Forms in Zoho Creator!

                                                                                                                Let’s make long applications easier to handle by dividing them into pages, adding a progress bar, and guiding users step by step through complex data entry. This would be a total game-changer for the user experience and could significantly boost completion
                                                                                                              • Email login error

                                                                                                                Login successfully but email page error
                                                                                                              • Shared Mailboxes Disappeared

                                                                                                                Zoho Mail users in our company haven't been able to see their Shared Mailboxes for the past few hours. I've checked with App and Web Access, but they can't access them. When I send emails to their addresses, I get no error messages. They're still visible
                                                                                                              • Remote Server is misconfigured

                                                                                                                Dear Team, I am unable to use email id as remote server is misconfigured. It would be really great if you could help on this and get this resolved. Thanks & Regard Rohit Gupta
                                                                                                              • why cant i access my email account. it keeps asking me for reverifiying my account by entering my password.

                                                                                                                I cant access my account. it keeps asking me for reverifcaton by entering my password. once its entered it asks for it over and over.
                                                                                                              • Free webinar alert on October 16 - Less Complexity, More Security: Workplace + Directory

                                                                                                                Hello Zoho Workplace Community! Security and productivity shouldn't be at odds—and with Zoho, they're not. Discover how Zoho Workplace + Directory delivers seamless collaboration with enterprise-grade security, all in one integrated ecosystem. Join our
                                                                                                              • Workdrive and ChatGPT Team Synced Connectors

                                                                                                                Hi, we want to be able to integrate Zoho Workdrive with OpenAI’s ChatGPT Team plan. Google Drive and OneDrive both offer this, zoho please catch up asap. We dont want to have to put our company files in google drive, we want to allow chatgpt Team edition
                                                                                                              • Alias Name (on items) use case in Zoho inventory

                                                                                                                Hey, Hope everyone is well. Wondering if anyone can shed some light on the use case of Alias Names on Products in Zoho Inventory? Cheers, Chris
                                                                                                              • Updating an Invoice Line Item's Discount Account via API Call / Deluge Custom Function

                                                                                                                I need help updating an invoice line item's discount account via API. Below is a screenshot of the line item field I am referring to. Now the field to the left of the highlighted field (discount account) is the sales income account. I am able to modify
                                                                                                              • Send e-mail with attachments

                                                                                                                Dear Zoho, How is that possible in Zoho Flow to send an e-mail with attachment?  Just a simple example: Zoho Flow checks my Zoho mails and if the conditions starts the trigger then I would like to send an email with the original email's attachment. Any idea? BR, Adam
                                                                                                              • How to I get checkboxes on a subform to update via deluge

                                                                                                                Hello, would someone be able to tell me what I'm doing wrong here? I am trying to take the contents of a Deals subform and add them to an invoice then update the checkbox on each row so that 'add to invoice' is unticked and 'invoiced' is ticked. The output
                                                                                                              • Unified customer portal login

                                                                                                                As I'm a Zoho One subscriber I can provide my customers with portal access to many of the Zoho apps. However, the customer must have a separate login for each app, which may be difficult for them to manage and frustrating as all they understand is that
                                                                                                              • Next Page