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


                                                                                                      ご検討中の方