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

                                                                                                              • Zoho Desk Limit for Comma Separated Queries

                                                                                                                Hi, I have just discovered a limit that I believed is not mentioned in any of Zoho's documentations. My search query looks like so: "query: {"accountId":"786050000091629966,786050000163589273,786050000163589427,786050000162753705,786050000162112971,786050000161987643,786050000160752868,786050000167089504,786050000167089378,786050000167089024,786050000167070005,786050000166295256,786050000128153693,786050000110560021,786050000046594575,786050000039106461,786050000002225356,786050000076889093,786050000047895103,786050000043365354,786050000044765191,786050000041790249,786050000040359116,786050000037945198,786050000024605077,786050000000525015,786050000155333895,786050000157741437,786050000000718125,786050000011574353,","departmentId":"786050000042648070","status":"Finished","sortBy":"createdTime","customField2":"cf_completion_date:2025-01-28T03:00:00.000Z,2025-10-28T03:00:00.000Z","customField3":"cf_billed:false"}"
                                                                                                              • Module Name doesn't exist

                                                                                                                I am trying to create a module named Activity, with plural Activities, but I have an error that module name already exists. This module is doesn't exist, and I don't have a single field called Activity or Activities.
                                                                                                              • Zoho Desk iOS and Android app update: AI powered: Reply Assistance and Refine Messages on IM module.

                                                                                                                Hello everyone! We are excited to introduce new AI powered features on the IM module of the Zoho Desk app. Reply Assistance: Reply Assistance generates suggested responses for incoming chat messages, which you can directly insert into the conversation
                                                                                                              • Is it possible to embed Youtube shorts?

                                                                                                                Hi Zoho desk support, This is Ryan from Accuver America. While I'm trying to create a knowledge base article with embed video, I ran into this issue. "www.youtube.com refuse to connect" A little bit background is that because this video is recorded on
                                                                                                              • Split functionality - Admins need ability to do this

                                                                                                                Admins should be able to split an expense at any point of the process prior to approval. The split is very helpful for our account coding, but to have to go back to a user and ask them to split an invoice that they simply want paid is a bit of an in
                                                                                                              • Delegates - Access to approved reports

                                                                                                                We realized that delegates do not have access to reports after they are approved. Many users ask questions of their delegates about past expense reports and the delegates can't see this information. Please allow delegates see all expense report activity,
                                                                                                              • How to include total km for multiple trips in expense report.

                                                                                                                Whenever I create a mileage report it only shows the total dollar amount to be reimbursed. The mileage for each individual trip is included but I also need to see the total distance for all trips in a report? How do I do this?
                                                                                                              • I didn't receive my domain verification mail

                                                                                                                I didn't receive my domain verification mail 
                                                                                                              • Get logged in user ID in Deluge script

                                                                                                                Hello all, How do I get the id of the logged-in user in a deluge script? the "zoho.loginuserid" function actually returns the users email address or whatever the user id they use to login to zoho with and not the id of the user record, and given that
                                                                                                              • Item Details Field - New Barcode / Document option?

                                                                                                                Is this a new feature??? its in both books and inventory.
                                                                                                              • Shared Mailbox - Mark as read for all users

                                                                                                                Hi all, Maybe someone can help me out. At the moment we have a shared mailbox without streams. When a users reads an mail or marks it as read other users will not see this. How can we resolve this? We now archive the mails when read and followed up. However
                                                                                                              • Can I export to PDF in Zoho Learn

                                                                                                                I have seen help pages where export to pdf options are available but I do not see that option available from the application. I see that exprt is available in my free trial version but that is only to html pages. I need to be able to export my manuals
                                                                                                              • Staff rules

                                                                                                                Hi! Do you people know what are the default staff rules when a new booking is created? We have two staff members in my team (me as the admin, and my employee). As we share the same services, I'm wondering how Zoho will pick the staff for new apointments.
                                                                                                              • Add Image Upload Field to Zoho Bookings Registration Form

                                                                                                                Hi, We would like to request the addition of an image upload field to the Zoho Bookings registration form. Currently, Zoho Bookings only supports text-based fields (e.g., Single Line, Multi-Line, Email, Checkbox, Dropdown, Radio Button, and Date), but
                                                                                                              • Merge Tags Output Incorrect Placeholder Text After CRM Sync

                                                                                                                Hi everyone, I’m experiencing an issue with merge tags in Zoho Campaigns after last sync of contacts and leads from Zoho CRM (days before everything worked perfectly). Here’s the situation (seems like a default configuration in Campaigns) : My leads have
                                                                                                              • UI Improvement - Ability to Collapse Flow

                                                                                                                The UI for Flow is generally pretty good. However, when multiple decision trees are used, the layout can get pretty convoluted and hard-to-follow (see one of my Flows below): In these cases, even the auto-arrange fails to make this something that a normal
                                                                                                              • Windows agent 2025_M02 release notes

                                                                                                                Agent Version: 111.0.3.300 Release date: 24 February, 2025 Various Major enhancements to improve overall performance and optimize the user experience. Squashed a few bugs to improve overall product quality.
                                                                                                              • Windows agent 2025_M01 release notes

                                                                                                                Agent Version: 111.0.3.299 Release date: 05 February, 2025 Major Enhancement: Live Monitor feature compatibility released. Major Enhancement: Updated Scaling for multi technician cases with Android and Web based viewers. Various other bug fixes and performance
                                                                                                              • how to record deferred revenue?

                                                                                                                Dear Zoho Team, We issue invoices relating to 12-month web hosting service. When we issue the invoice, we should record the entire amount of the invoice as DEFERRED REVENUE (ie. $10 x 12 mths = $120, balance sheet item). After the particular month of the hosting service, $10 of revenue has been earned and deferred revenue amount will be $110. We must keep adjusting the balance sheet and income statement over the course of the service until the company has fulfilled its obligation of services and
                                                                                                              • Narrative 13: Importing your data

                                                                                                                Behind the scenes of a successful ticketing system: BTS Series Narrative 13: Importing your data When importing data into an application, it is crucial to prevent data loss or duplication. These types of errors can hinder the development of a clean and
                                                                                                              • Blueprint Not Triggering When Lead Status Is Updated by Workflow (IndiaMART Integration)

                                                                                                                I have set up a blueprint that triggers when a lead’s status is “New Lead.” Our CRM is integrated with IndiaMART, and when leads are created from IndiaMART, their Lead Status is initially set to None. To handle this, I created a workflow that automatically
                                                                                                              • Update Subform in specific field(Status) without affecting other fields in Zoho CRM using Deluge?

                                                                                                                Scenario: PRODUCT Module(change name Plot) in any product status change From Available to Booked then on PROJECT Custom Module have Subform So, Subform name is Property Details now in that Subform 1 field is STATUS that update according to  product status
                                                                                                              • YouTube Live #2: Agreement Intelligence with Zoho Sign's eSign AI assistant

                                                                                                                Hi there, We're back again with our YouTube live series and this time, we'll take you through our holistic agreement intelligence powered signature workflows. Struggling to draft an agreement? Need help double-checking clauses and going through complicated
                                                                                                              • Can I Build a POS using ZOHO creator and integrate it with ZOHO Books?

                                                                                                                Hello,  I have a Zoho Books account and I was wondering if I can have a POS system that integrates with it. Primarily with Inventory, Customers and Payment and ofcourse Create invoices and credit notes.   So, would Zoho creator provide me with this solution?  Thank you, 
                                                                                                              • An important update for Zoho Cliq desktop users

                                                                                                                The latest version of the Zoho Cliq desktop app (v1.8.0) will no longer be supported on macOS 10.15 Catalina and earlier versions. This is because the framework we use (Electron) no longer supports some older macOS versions. If you’re using macOS 10.15
                                                                                                              • Zoho Projects - Visual improvement to parent and sub-task relationship

                                                                                                                Hi Projects Team, My feature request is to improve sub-task visibility. Please see screenshot below. I really think parent child relationships could be visually improved. Even if the first letter of the parent task was inline with other same level tasks
                                                                                                              • New Toolbar in Zoho Sheet

                                                                                                                We have revamped our toolbar design in this new version of Zoho Sheet. Below are some screenshots to help you get accustomed to this new interface. Click on the picture below to view the animated image in its original size. Scroll down this post to learn about the changes. Highlight of Changes: The previous format tab is now split into 2 tabs - Home and Format. The Home tab contains the commonly used functions and the Format tab holds formatting related options. Under the Home tab towards the far
                                                                                                              • Zoho inbuilt Telephony made a lot of issues!

                                                                                                                Hi there, I am a user that I am working with zoho inbuilt telephony around 1 month. Non of my colleagues are happy with this app! most of the time customer cannot hear my customer service team, customers say our voice is breaking. whenever Telephony support
                                                                                                              • Sending workflow notifications using popular chat services

                                                                                                                Hello everyone, We have introduced instant and scheduled notifications on some of the most popular chat platforms to facilitate easy collaboration, quick action, and wider reach. Workflow notifications can be sent to the following chat platforms: Zoho
                                                                                                              • Webhook not firing.

                                                                                                                I created a webhook using the Web UI, it looks very nice and the testing worked without an issue, but when i save/ update a ticket, the webhook is not firing. Here are the details of the web-hook i get from using the API "modifiedTime": "2019-10-22T09:23:37.380Z",
                                                                                                              • Adding Images to a Quote in Zoho CRM

                                                                                                                We are currently preparing to use Quotes in Zoho CRM and we are building out our Quote templates.  We came across an issue of not being to add Images of the products to the Quote - specifically in the body of the Quote templates.   This is a problem,
                                                                                                              • Applications built with Zoho Creator

                                                                                                                Hi, I’m really interested in seeing how others have built their application using Zoho Creator, especially those designed for external users (clients, vendors, or the public). If you’ve developed something along those lines and don’t mind sharing, I’d
                                                                                                              • Is it posssible to add Asap Widget on Wordpress?

                                                                                                                I have tried to add the ASAP widget so users could iniciate chats and see the KB information but nothings seems to work. I have tried to add the script using a php snippet that adds the to the footers and also tried one for the header in the functio
                                                                                                              • Require ticket resolution

                                                                                                                Hi Zoho team, Is there a way to require resolution even if an agent did not use a blueprint? for example, our blueprint has a "resolve" transition but what if agent revoked blueprint and manually set the status of ticket to closed? Is there a way where
                                                                                                              • Tables from ZohoSheets remove images when updated from source

                                                                                                                I have a few tables from a ZohoSheet in a ZohoWriter document that will remove the images in the cells when I refresh from the source. The source still has the images in the table when I go to refresh. After updating from the source, as you can see the
                                                                                                              • API Pagination Error: 'from' Parameter Limit

                                                                                                                Hello, I am encountering an error while paging through the Zoho Desk API results: Status code: 422 - {"errorCode":"UNPROCESSABLE_ENTITY","message":"The value passed for field 'from' exceeds the range of '0-4999'."} Is 5000 the maximum number of records
                                                                                                              • How to go to the next open ticket in the queue when agents closes ticket

                                                                                                                Zoho Desk When agent closes a ticket - eg when they choose 'Send and Close" - where is the setting that automatically redirects them to the next open ticket in the queue?
                                                                                                              • CRM verify details pop-up

                                                                                                                Was there a UI change recently that involves the Verify Details pop-up when changing the Stage of a Deal to certain things? I can't for the life of me find a workflow or function, blueprint, validation rule, layout rule ect that would randomly make it
                                                                                                              • Custom templates for calendar report

                                                                                                                What about being able to design custom templates for the calendar report, as well as for other types of reports? I think more users are waiting for this.
                                                                                                              • Print a price list or price book

                                                                                                                Hi Community. Am I right in concluding that Zoho has no functionality to print a price list from either Zoho CRM, Zoho Inventory or Zoho Books? I won't get stuck on the fact that Zoho doesn't sync price books between Zoho CRM and Books/Inventory (more
                                                                                                              • Next Page