Rodger's helpful deluge scripts #4 - Bulk updating records using a deluge function

Rodger's helpful deluge scripts #4 - Bulk updating records using a deluge function

One of this things I love about Zoho is that there's so many ways to accomplish something. Want to mass update some records? Sure, we have the Mass Update function to update a single field. Need to update more than 1 field? Sure, we have she Sheet view, but what if you need to incorporate logic decisions or calculations into your record update?

You could use sheet view, but that's limited to 100 records at a time, and what if there's multiple logic decisions to be made? Well, you use a deluge function.

This is the function I use when dealing with relatively small numbers of records. It can work well up to a couple of thousand records:

Firstly you're going to create a standalone function with the following arguments:

v_module (string data type)
v_records (integer data type)

Then we're going to use the following code:

  1. // Create a list of pages based on the number of records in the module. This will take the  number of records, v_records, 
  2. // divide it by 200 (200 records per page) and then round up to the nearest whole number. It will then use this number to repeat the text "1,"
  3. // and finally, it will remove the last "," and convert the string into a list

  4. l_pages = repeat("1,",(v_records/200).ceil()).removeLastOccurence(",").toList();
  5. l_bulkUpdate = List(); // Create a list to hold the records for the bulk update
  6. v_page = 1; // set the first page number
  7. for each page in l_pages
  8. {
  9. l_records = zoho.crm.getRecords(v_module,v_page,200);
  10. for each record in l_records
  11. {
  12. m_record = Map();
  13. m_record.put("id", record.get("id"));
  14. m_record.put("updated", true); // Create a temporary checkbox in your module to track whether the record has been updated
  15. //
  16. // insert your code here
  17. //
  18. l_bulkUpdate.add(m_record);
  19. if ( l_bulkUpdate.size() == 100 ) 
  20. {
  21. bulkUpdate = zoho.crm.bulkUpdate(v_module, l_bulkUpdate);
  22. info "Bulk Update: " + bulkUpdate;
  23. l_bulkUpdate.clear(); // Clears the bulk update list after sucessful bulk update
  24. }
  25. }
  26. v_page = v_page + 1; // Index the page number by 1
  27. }
  28. if ( l_bulkUpdate.size() > 0) 
  29. {
  30. bulkUpdate = zoho.crm.bulkUpdate(v_module, l_bulkUpdate); // Final bulk update if the list size is greater than zero but less than 100
  31. info "Bulk Update: " + bulkUpdate;
  32. }

Now put your logic in where it says "// insert your code here" then you can save and execute.

Because we use the put the module name in a variable, you can use this code for any module and will be prompted for the module name and the record count when you click "Save and Execute"

This comes with a warning however - DO NOT TRY THIS IN PRODUCTION IF YOU'RE TESTING YOUR CODE. ALWAYS TEST THIS IN SANDBOX FIRST BEFORE USING IT IN PRODUCTION!!

Also, test out your code on a single record before testing out your bulk update. That way you won't have to undo a huge mess if something goes wrong.

This is by no means the ONLY way to bulk update records using a deluge function and will not work if you have tens or hundreds of thousands of records.

    Access your files securely from anywhere

        All-in-one knowledge management and training platform for your employees and customers.






                              Zoho Developer Community




                                                    • Desk Community Learning Series


                                                    • Digest


                                                    • Functions


                                                    • Meetups


                                                    • Kbase


                                                    • Resources


                                                    • Glossary


                                                    • Desk Marketplace


                                                    • MVP Corner


                                                    • Word of the Day


                                                    • Ask the Experts





                                                              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

                                                                                                                • Le cauchemar de PEPPOL avec Zoho Books

                                                                                                                  Après de longues hésitations — car je défends toujours les produits Zoho malgré leurs imperfections —, je me suis décidé à poster cet avis sur ce forum. En effet, depuis plus de 5 mois, les nombreux soucis relatifs à la facturation par PEPPOL semblent
                                                                                                                • Accepting Event from Outlook Client

                                                                                                                  I've noticed this behavior for a few years now. If an Event is created from CRM and sent to participants and the participant accepts the invitation using Outlook client, Zoho event won't be updated as "Going" it only works if the recipient accepts it
                                                                                                                • Link webform to a job opening

                                                                                                                  I have a webfrm embeded on my website and everytime a candidates fill the form, their candidate status is to new. Is it possible that it links to a specific job opening instead of me having to assing it manually ? Thanks
                                                                                                                • Zoho CRM Integration Form + Custom Fields

                                                                                                                  Hi! I've created an Integration Form from Zoho CRM's Vendors Module, but I can choose a few standard fields and no custom fields I've created in Zoho CRM. There is a plan to add this feature soon? Thanks in advance.
                                                                                                                • Canvas Detail View Related List Sorting

                                                                                                                  Hello, I am having an issue finding a way to sort a related list within a canvas detail view. I have sorted the related list on the page layout associated with the canvas view, but that does not transfer to the canvas view. What am I missing?
                                                                                                                • Overview on users IMAP settings

                                                                                                                  We have about 30 users who all have the channels/email/email configuration/IMAP integration/O365 enabled and emails are synchronized. Here my problem: Passwords for the email accounts are expiring on individual bases and most of the users forget to update
                                                                                                                • Cross Module Filtering – Use Fields from Lookup modules in Custom Views criteria and Advanced Filters

                                                                                                                  Hello everyone, Zoho CRM now enables you to achieve deeper filtering of records in a module, using fields of a lookup, thereby enhancing your data management experience manifold. This filtering based on lookup module fields is now available in advanced
                                                                                                                • Custom Portal URL causing SAMEORIGIN error with embedded Page snippet

                                                                                                                  In my app, I have a page that embeds another page. The URL that I have for the embedded page starts with https://creatorapp.zoho.com but the custom domain I have set up is https://kors.kerndell.com. Because the user logged into the app at https://kors.kerndell.com,
                                                                                                                • Recent enhancements made to workflow rules

                                                                                                                  Greetings, I hope all of you are doing well. We're happy to announce a few recent enhancements we've made to Bigin's workflows. We'll go over each one in detail, but for now these updates can be broadly categorized into two parts: Enhancements to workflow
                                                                                                                • How do I get my cell height to auto adjust?

                                                                                                                  I'm evaluating Zoho Sheet as a replacement for Google Spreadsheet. Using latest version of Safari, and experiencing the same issues in Chrome. A few bugs/things I can't figure out: Auto adjusting cell height when importing from Google Docs or creating a new document Turning off the auto date formatting for X.Y.Z where they are all integers.. (This is extremely important, as our requirements are written as outlines.. "X.Y.Z" corresponds to a requirement ID.. which is then turning into a date) The
                                                                                                                • Zia Agent activation in Zoho Desk forces new Organization creation instead of deploying to existing one

                                                                                                                  While attempting to complete the deployment and activation sequence of a new Zia Agent within our existing Zoho Desk environment, the activation process failed on the user interface, throwing a generic error (see print). However, despite the activation
                                                                                                                • Marketing Tip #36: Optimize your online store for AI search

                                                                                                                  Search is changing fast. Along with traditional search engines, AI-powered search and recommendation experiences are becoming a bigger part of how customers discover products online. Stores that are well-organized, descriptive, and consistent are more
                                                                                                                • Create a "My saved custom themes" section in Zoho Forms

                                                                                                                  Hi! I created lots of forms for my company that we embed on the website with a custon design. It is a pain not to be able to save a custom layout as a template and just not to have to do it again! So could you add a gallery like : "My saved themes" ?
                                                                                                                • Automating CRM backup storage?

                                                                                                                  Hi there, We've recently set up automatic backups for our Zoho CRM account. We were hoping that the backup functionality would not require any manual work on our end, but it seems that we are always required to download the backups ourselves, store them,
                                                                                                                • Zoho CRM Kiosk question – Passing Screen Fields to a Function

                                                                                                                  I am building a Kiosk in Zoho CRM to create new Supplier (Vendors) records. Current setup: Screen 1 contains user input fields: Supplier Name (Vendor_Name) First Name (First_Name) I created a Deluge function: createSupplier(vendor_name, first_name) The
                                                                                                                • Introducing Spotlight Forms

                                                                                                                  Hey form builders! If someone opens your form, sees the wall of fields ahead, and quietly closes the tab. It may not be because the questions were hard. It could be because the experience felt like too much. Which is why we have now introduced a new form
                                                                                                                • Client Script Button in Related List become invalid

                                                                                                                  Hi, I am the admin of our organization. And I setup a client script button in related list to raise payment refund request While this button become non selectable recently. I believe there is something wrong from zoho as this button had run for a year.
                                                                                                                • BUG and HANGUP - Add Row with Fields DOUBLES the amount of rows instead of Adding Just 1 Row

                                                                                                                  As it says in the title, there is a bug with forms generated with Zoho Writer where the Add Row With Fields ends up DOUBLING the amount of rows instead of Adding just 1 row.
                                                                                                                • Delivery Note without services

                                                                                                                  Hi all, It there a possibility to create a delivery note from an invoice without the listed services "idem type: service"? Thank you in advance, Michel
                                                                                                                • Forms cannot be accessed.

                                                                                                                  https://forms.zoho.com/ is not available, please help to fix
                                                                                                                • Digest Mai - Un résumé de ce qui s'est passé le mois dernier sur Community

                                                                                                                  Chers utilisateurs, Un nouveau mois se termine au sein de la communauté Zoho France. Découvrons ensemble un résumé des activités du mois de mai. Quatre ans après son lancement, Zoho Marketing Plus continue d’évoluer avec une ambition claire : offrir aux
                                                                                                                • Ability to run report over 180 days

                                                                                                                  Is there a reason Zoho limits the ability to run reports for records older than 180 days? In my view, the only reason I can think of is that it forces us to pay for Advanced Analytics (which I do).
                                                                                                                • Canvases Auto-Skewing/Adding Scroll Bars When They Were Not There Prior

                                                                                                                  Is anyone else noticing rendering issues in their canvases today? It seems to be mainly icons which now have scroll bars added which makes them all look off, though some fields seemed to revert to squished length as well. Were the icons replaced with
                                                                                                                • [URGENT] Cannot access Functions tab in CRM

                                                                                                                  Navigating to /settings/functions/myFunctions gives this error message: "Sorry, something went wrong. Please try again later." I raised this issue with Zoho Support on Monday (3 days ago) but have not heard back. I'm sure it's clear how important it is
                                                                                                                • Important changes to note for Zoho Sign users in Saudi Arabia

                                                                                                                  Dear Zoho Sign users, If your Zoho Sign account is hosted in our Saudi Arabia data centre, here's an important update on digital signature certificates in the Kingdom of Saudi Arabia. What's changing Going forward, the "Sign via Zoho Sign" option will
                                                                                                                • Cloning a View

                                                                                                                  When I clone a View, it doesn't make a copy; it only creates a new copy with the same default fields as if I were creating a new view. What is the purpose of cloning if it doesn't bring in the same fields? Thanks Rudy
                                                                                                                • Zoho Desk MCP doesn't expose all functions

                                                                                                                  Hello, I'd like to be able to draft (rather than send) ticket replies using Claude Cowork. However, the Zoho Desk MCP doesn't currently offer that, despite it being available in the API (https://desk.zoho.com/DeskAPIDocument#Threads#Threads_DraftEmailReply).
                                                                                                                • Number of Reopn

                                                                                                                  Hi Zoho, Is there any appropriate API call for This URL "http://support.zoho.com/api/v1/dashboards/reopenedTickets?...." what I thought is the resulting output of this call has data for number of reopen... "https://desk.zoho.com/api/v1/tickets/" + Ticket_ID
                                                                                                                • Can I use merge tags with a conditional clause?

                                                                                                                  Similar to Mailchimp's "IF / ELSE / ENDIF" functionality, I want to be able to display a sentence with a personalised field only if that merge tag is not empty for the given record. Is this possible on Zoho Campaigns? See http://kb.mailchimp.com/article/how-do-conditional-smart-merge-tags-work for how it works on Mailchimp. Thanks Phil
                                                                                                                • Question - why no way to input a 'tool description' and 'tree of 'tools'

                                                                                                                  Every business is different, with different business processes. To be truly useful Zoho MCP needs to have user editable tool descriptions (or ruleset) and a 'tool tree' so that the LLM is context aware when being used. For example, the tool description
                                                                                                                • Personalize your booking pages with Custom CSS

                                                                                                                  Greetings from the Zoho Bookings team! We’re introducing Custom CSS for Zoho Bookings, designed to give you complete control over the look and feel of your booking pages. With this new feature, you can upload your own CSS file to customize colors, fonts,
                                                                                                                • CRM API v9?

                                                                                                                  v8 has been around for a while. any plans / estimates for v9?
                                                                                                                • Associate records via the Multi-select lookup RELATED LIST via API

                                                                                                                  In the REST API, is there a way to associate records for a multi-select lookup related list other than via the linking module? There are two methods for the lookup: 1. via insert records API 2. via the linking module ...as described in https://help.zoho.com/portal/en/community/topic/kaizen-125-manipulating-multi-select-lookup-fields-mxn-using-zoho-crm-apis
                                                                                                                • Calendar report with order options and more quick view templates

                                                                                                                  I think many of us regularly work with calendar-style reports. It would be great to be able to customize the quick view with new templates and have options to sort the entries for each day of the calendar by different criteria. I think this is an interesting
                                                                                                                • Kaizen #125 Manipulating Multi-Select Lookup fields (MxN) using Zoho CRM APIs

                                                                                                                  Hello everyone! Welcome back to another week of Kaizen. In last week's post in the Kaizen series, we discussed how subforms work in Zoho CRM and how to manipulate subform data using Zoho CRM APIs. In this post, we will discuss how to manipulate a multi-select
                                                                                                                • Writer is horrible

                                                                                                                  Form filling is about unusable for complex forms! I am so tired of it. GET IT TOGETHER ZOHO.
                                                                                                                • Zoho Books and TRAINING SALES receipt label for eTims?

                                                                                                                  Hi, Can Zoho Books implement TRAINING SALES receipts and push them to eTims for test? In other words how can we send to Zoho or even create in Zoho training mode invoices and TEST the workflow POS>Zoho Books>eTims and back without actually registering
                                                                                                                • Workflow Assistance in Zoho CRM

                                                                                                                  Our client's sales team visits customers on-site and currently fills a physical paper form to capture customer details, and then separately re-enters the same data into Zoho CRM via the mobile app — resulting in double data entry. We want the salesperson
                                                                                                                • How do I post a new question in Zoho Community forums?

                                                                                                                  Hi everyone, I’m new to the Zoho Community and I’m trying to figure out how to properly create and publish a new topic in the forum. When I visit the community page, I can’t clearly find the option like “Add Topic” or “Post Question.” Could someone guide
                                                                                                                • Any Zoho Books users in the Kenyan Hospitality industry? How to set service items for eTims?

                                                                                                                  Hello, We are opening a coffee shop in Kenya and would like to know if there are any Zoho books users in hospitality service industry in Kenya? We would love to know: 1. how do you cope with the absence of the mandatory Tourism Levy 2% tax option? 2.
                                                                                                                • Next Page