Records Updates using Workflow-Triggered Deluge Functions

Records Updates using Workflow-Triggered Deluge Functions

Hey !
Happy New Year everyone, and welcome to the first Kaizen of 2024!

In this week's Kaizen, we will address this query raised in our developer community on how a workflow triggers a Deluge function to update the status of a field in related records after the associated parent record is deleted.

------------------------------------------------------------------------------------------------------------------------------------

Use Case

The user creates a function and associates it with a workflow, which will be triggered automatically when a record in the Purchase Orders module is deleted. The function updates the value of the Stock Status field in each related record i.e. the records in the Stock Records custom module that are associated with the Purchase Orders module. This eliminates the need for users to manually change the status of each stock associated with the deleted parent record from Occupied to Available. Consequently, this ensures that available stocks can be readily identified for other customers.

API Enhancement

From V6 onwards, you can fetch the related records of a deleted record using the Get Related Records of a Deleted Record API. It is important to note that this API allows the retrieval of related records associated via lookups. For more detailed information, please refer to the API help documentation.

Retrieving the related record of a deleted parent record using API

Sample




Create a custom function and associate with the workflow

To implement this automated workflow, a custom function can be executed.
n = 1000; //Upto 100,000 records can be fetched. In our case, we are fetching 100 records in a single call, so the code iterates 1,000 times.
counter = leftpad("1",n).replaceAll(" ","1,").toList();
i = 1;
for each  el in counter
{
reqUrl = "https://www.zohoapis.com/crm/v6/Purchase_Orders/deleted/" + poid.toString() + "/Stock_Records1?fields=Stock_Status&page=" + i.toString() + "&per_page=100";
response = invokeurl
[
url :reqUrl
type :GET
connection:"zohocrm"
];
lis = List();
i = i + 1;
for each  stockList in response.get("data")
{
idData = stockList.get("id");
mp = Map();
mp.put("Stock_Status","Available");
mp.put("id",idData);
lis.add(mp);
}
updRes = zoho.crm.bulkUpdate("Stock_Records",lis);
if(!response.get("info").get("more_records"))
{
break;
}
}


The script initiates an API call to retrieve the unique IDs of deleted records in the Purchase Orders module. The URL includes parameters for the page number and records per page, and the response is stored in the response variable. 

The script iteratively fetches stock records associated with the deleted purchase order, updating the Stock Status for each record to Available in bulk operations. The loop continues until the more_records value in the response is false, represents the completion of record retrieval. Note that you can fetch 100000 records using pagination.

Associating the function with a workflow

The Workflow updates the value of the Stock Status field in the related records when a record in the Purchase Orders module is deleted.

The below GIF shows how to associate the function with a newly created workflow.



For more details, refer to Configuring Workflow Rules

The GIF below illustrates the final output:
The GIF demonstrates the functionality and execution of the code.



We trust that this post meets your needs and is helpful. Let us know your thoughts in the comment section or reach out to us at support@zohocrm.com

Stay tuned for more insights in our upcoming Kaizen posts!

Happy Coding!

Previous Kaizen Post : Kaizen #118 - Mass Delete Records Across Modules 


Cheers!
------------------------------------------------------------------------------------------------------------------------------------

Additional Reading:

    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





                                                        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 Writer

                                                                                          Get Started. Write Away!

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

                                                                                            Zoho CRM コンテンツ










                                                                                              Nederlandse Hulpbronnen


                                                                                                  ご検討中の方




                                                                                                        • Recent Topics

                                                                                                        • Getting error while while deleting from Activities Object

                                                                                                          I am trying hit this endpoint: - DELETE https://www.zohoapis.in/crm/v2.1/Activities?ids=725820000001141076%2C725820000001143056 HTTP/1.1 But getting the below error: - {"code":"INVALID_REQUEST_METHOD","details":{},"message":"The http request method type
                                                                                                        • Zoho CRM Developer Series - Queries

                                                                                                          Hey everyone! We’re excited to invite you to our next Zoho CRM Developer Series focused on Zoho CRM Queries, happening on June 5, 2025 and June 26, 2025. Whether you're working on CRM customizations, integrating with third-party services, or just curious
                                                                                                        • Announcing Zoho Community Developer Bootcamps in India – Extensions

                                                                                                          Hey everyone! We're back with another line-up of Zoho Community Developer Bootcamps in India! Following the success of the first leg of bootcamps on Extensions, we're now ready with the second leg. These bootcamps focus on empowering developers of all
                                                                                                        • Bidirectional sync between Zoho Bookings and Zoho CRM - Part 1

                                                                                                          Hey, community members! The default integration between Zoho CRM and Zoho Bookings is unidirectional, which means that any appointments booked, rescheduled, or deleted in Zoho Bookings will be reflected in Zoho CRM. However, any modifications made to
                                                                                                        • Announcing New Features in Trident for macOS (v.1.19.0)

                                                                                                          Hello everyone! Trident for macOS is here with interesting features and enhancements to elevate your workplace communication. Let's take a quick look at them. View and manage .pst files. A .pst (Personal Storage Table) file is an Outlook Data Storage
                                                                                                        • View Answer Bot conversations?

                                                                                                          We are trialing Zia and are experimenting with Answer Bot on our knowledge base. So far so good! Management asks me if it is possible to view Answer Bot conversations, the purpose being to look over its shoulder and confirm that it is working as des
                                                                                                        • ZOHO Sheet View for Activities

                                                                                                          Hello I am beginning to look at importing previous events into activities as utilizing events as timeslips for engagements, we have added fields such as duration, billable, etc. However to use Events on a regular basis would require the ability to use
                                                                                                        • Create Login Pages in Zoho Creator

                                                                                                          Hello everyone, I have a question, is it possible to create a login page that is connected to the database in the zoho creator report? The email and password typed in the page will match the one in the database. attached is the image of the page that
                                                                                                        • Unveiling Zoho CRM's New User Interface - The NextGen UI

                                                                                                          Hello Everyone, Last Wednesday, May 14th,2025, we announced the public release of Zoho CRM For Everyone, our most significant update yet. This release brings a modernized CRM experience with a redesigned user interface, new capabilities for cross-functional
                                                                                                        • 【参加無料】6月ユーザー交流会 参加登録 受付開始(東名阪の3都市開催)

                                                                                                          ユーザーの皆さま、こんにちは。コミュニティチームの藤澤です。 6月に東京 / 大阪 / 名古屋の3都市でユーザー交流会を開催します! 各地域のユーザーによるZoho 活用事例や、自社活用・運用について参加者同士で情報交換が出来るグループワークなどを予定しています。 ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー ※以下、記載順で開催予定 🟠 大阪ユーザー交流会 6/5(木) 18:00-20:20 ・会場:APイノゲート大阪 ・予定セッション ┗Zoho サービス活用事例:Zoho
                                                                                                        • Invalid URL error when embedded sending url into iframe for my website when using in another region

                                                                                                          Hi team, My site is currently working on integrating your signature feature as part of the system functionality, it's working great but recently there's been a problem like this: After successfully creating the document, i will embed a sending url into
                                                                                                        • Need details on search criteria for zoho.crm.searchRecords

                                                                                                          Hi, If I understood correctly the integrated functions (getRecords, searchRecords, etc..) I can use inside Functions in Zoho CRM are actually using the Zoho CRM V2 API. I am looking for all the field types and criteria I can use with searchRecords. The
                                                                                                        • Custom Serial numbers in Inventory tied to customers

                                                                                                          Hello, We have both software and hardware serial numbers that we need to track for active customers in the field. We do not know the serial numbers for the software until the customer buys it as its not a stock item but something we order and deploy for
                                                                                                        • Kit Items Breaking Automations - "Provide mapped components for all kit items"

                                                                                                          This has been brought up in other threads, but I believe this issue warrants its own topic. Whenever a sales document (Estimate, Sales Order, Invoice) is created or manipulated programmatically, trying to include a Kit as an Item throws this error: "Provide
                                                                                                        • What’s New in Zoho Inventory | April 2025

                                                                                                          Hello users, April has been a big month in Zoho Inventory! We’ve rolled out powerful new features to help you streamline production, optimise stock management, and tailor your workflows. While several updates bring helpful enhancements, three major additions
                                                                                                        • Issue with inventory and shopify

                                                                                                          Hello! We're having some issues with Inventory not synchronizing all our products with our shopify store. We've tried multiple times to synchronize them. We have multiple locations and it seems to just be getting a part of the inventory. When we sell
                                                                                                        • Add an option to disable ZIA suggestions

                                                                                                          Currently, ZIA in Zoho Inventory automatically provides suggestions, such as sending order confirmation emails. However, there is no way to disable this feature. In our case, orders are automatically created by customers, and we’ve built a custom workflow
                                                                                                        • Deluge script for purchase receive

                                                                                                          Trying to create purchase receives.... receive.put("purchaseorder_id",poId); // purchase order associated ... receive.put("line_items",itemList); result = zoho.books.createRecord("purchasereceives", orgId, receive); info result;...... {"code":9,"message":"Purchase
                                                                                                        • ZOHO BOOKS - RECEIVING MORE ITEMS THAN ORDERED

                                                                                                          Hello, When trying to enter a vendor's bill that contains items with bigger quantity than ordered in the PO (it happens quite often) - The system would not let us save the bill and show this error: "Quantity recorded cannot be more than quantity ordered." 
                                                                                                        • Automatic Pick LIst

                                                                                                          The pick should have the feature to send you to the FIFO location and tell you from wich bin you should get the product. Depending on FIFO LIFO or what we choose
                                                                                                        • Picker users

                                                                                                          Hi FOr bin location we are starting to use Android app. The users are allowed to chance the asignee, but they are the Asigneed persons. We should have the avility to choose or setup these fields.
                                                                                                        • Zoho Inventory MobileApp compatible with barcode scanners such as Zebra

                                                                                                          Hi, Although the Zoho Inventory App is working with a scanner mode taken directly through the cell phone which I do not consider it as efficient, I would like to know when are you planning an update on the app so it can be compatible with bar code scanners
                                                                                                        • Work Orders / Bundle Requests

                                                                                                          Zoho Inventory needs a work order / bundle request system. This record would be analogous to a purchase order in the purchasing workflow or a sales order in the sales cycle. It would be non-journaling, but it would reserve the appropriate inventory of
                                                                                                        • More Payment Gateways For South Africa

                                                                                                          Hello, please add more payment gateways that cater for South Africa to the Zoho ecosystem. Yoco - pay now with card (integrated but there is a problem) Others to consider Payflex.co.za - pay now with card or pay later using credit from payflex Float.co.za
                                                                                                        • Zoho Inventory Feature Roadmap Visible To All

                                                                                                          Hello, please consider making your feature roadmap visible to us users so that we know what to expect in future. This may appease current users who are seeking clarification on feature implementation dates, so that they can make an informed decision whether
                                                                                                        • Kaizen #147 - Frequently Asked Questions on Zoho CRM Widgets

                                                                                                          Heya! It's Kaizen time again, folks! This week, we aim to address common queries about Zoho CRM Widgets through frequently asked questions from our developer forum. Take a quick glance at these FAQs and learn from your peers' inquiries. 1. Where can I
                                                                                                        • Sync Zoho Docs and Google Drive

                                                                                                          Sync Zoho Docs and Google Drive -  how can I do it?
                                                                                                        • Compensation | Salary Packages - Hourly Wage Needed

                                                                                                          The US Bureau of Labor Statistics says 55.7% of all workers in the US are paid by the hour. I don't know how that compares to the rest of the world, but I would think that this alone would justify the need for having an hourly-based salary package option.
                                                                                                        • Is it possible to link a CRM field or Zoho User to a ticket auto assign function.

                                                                                                          Dear Support, I have a unique situation at our company. So I know it might be able to link a ticket to the client account owner from the CRM. However, is it also possible to link an email field, username or other field in the CRM to a new ticket created
                                                                                                        • Boost your Zoho Desk's performance by archiving tickets!

                                                                                                          The longer your help desk operations are, the more likely it is to accumulate tickets that are no longer relevant. For example, ticket records from a year ago are typically less relevant than currently open tickets. Such old tickets may eventually lead
                                                                                                        • How to overcome Zoho Deluge's time limit?

                                                                                                          I have built a function according to the following scheme: pages = {1,2,3,4,5,6,7,8,9,10}; for each page in pages { entriesPerPage = zoho.crm.getRecords("Accounts",page,200); for each entry in entriesPerPage { … } } Unfortunately, we have too many entries
                                                                                                        • Drill Down - Pivot Table

                                                                                                          Is there anyway to have drill down options in pivot tables like in the chart function?
                                                                                                        • Allow Zoho form to send to one of our ogranizations groups

                                                                                                          All emails from the form submission are being held for moderation. I have permissions set to organization members, and I think I have the forms setup in our DMARC
                                                                                                        • Kanban view - which modules support this view?

                                                                                                          Recently (a few days ago), we started exploring Zoho Recruit and like to use Kanban view to visualise the data in different modules. I just found out from emailing Zoho Support that they need to enable Kanban view for different modules (why?). Which modules
                                                                                                        • Email notification for followers

                                                                                                          Is there a way to enable email notification for followers of a support ticket? ie: Ticket #123 is owned by Agent#1, Agent#2 adds themselves as a follower. Whenever ticket #123 receives an email from the customer, Agent#1 receives an email. Agent#2 would
                                                                                                        • Prevent duplicate with custom fields?

                                                                                                          I was wondering something about custom field/custom modules in Zoho Desk. For some reason you can make a custom field mandatory but not unique? For example, if I create a custom module to manage equipment and renewal and make a field serial number no
                                                                                                        • Remove the dot menu and + sign on sub form

                                                                                                          If I don't want the user to be able to add more entries on a subform, am I able to remove the dot menu and the + sign?
                                                                                                        • Writing Checks to Employees for Reimbursable Expenses

                                                                                                          I couldn't find a way to write a check through books or expense to an employee for reimbursable expenses. The expense created an entry in the system with a debit (expense) credit (liability). I entered a bill and used the liability account so it would
                                                                                                        • Peppol Malaysia API

                                                                                                          Hi Zoho Books, my country Malaysia will going to implement "Peppol" (E-Invoicing), starting 1 Jul 2025 for all businesses. The government intends to provide API for accounting app. The workflow involves creating an invoice from accounting app, triggers
                                                                                                        • Pipeline in Custom Modules

                                                                                                          I love the way the Sales Pipeline looks and functions with reports. I would like to add the save pipeline features and visualization to a custom module, however, I only see that these pipelines are only available for the Deals module. Is there a way to add pipelines to custom modules?
                                                                                                        • Next Page