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:

    • Sticky Posts

    • Kaizen #197: Frequently Asked Questions on GraphQL APIs

      🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
    • Kaizen #198: Using Client Script for Custom Validation in Blueprint

      Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
    • Celebrating 200 posts of Kaizen! Share your ideas for the milestone post

      Hello Developers, We launched the Kaizen series in 2019 to share helpful content to support your Zoho CRM development journey. Staying true to its spirit—Kaizen Series: Continuous Improvement for Developer Experience—we've shared everything from FAQs
    • Kaizen #193: Creating different fields in Zoho CRM through API

      🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
    • Client Script | Update - Introducing Commands in Client Script!

      Have you ever wished you could trigger Client Script from contexts other than just the supported pages and events? Have you ever wanted to leverage the advantage of Client Script at your finger tip? Discover the power of Client Script - Commands! Commands
      • Recent Topics

      • Why am I getting event Pop-up Notification for events that have been cancelled?

        Why is Calendar Notification still popping up for events that have been cancelled or changed? Each time events are cancelled or changed, I have observed that I am still getting notifications for them. Below is a sample pop-up notification for one of the
      • Whatsapp Limitation Questions

        Good day, I would like to find out about the functionality or possibility of all the below points within the Zoho/WhatsApp integration. Will WhatsApp buttons ever be possible in the future? Will WhatsApp Re-directs to different users be possible based
      • Create a draft in reply to an email via Emails API

        Hi, I’d like to use the outgoing webhook to automatically create a draft reply to incoming mail. How can I use the Emails API to create a draft reply that is linked to an existing email thread? I couldn’t find the relevant method in the documentation.
      • India Tech Support

        Is there no phone tech support number for India? And no chat facility either?
      • Billing Management: #1 Billing an Universal Business Routine

        Hello, As the saying goes, "Do the hardest job first", we started with the complex subject in finance, revenue management, which is considered to be the backbone for any business. Now, let's shift our focus and take a deep dive into this Billing Management
      • Show/ hide specific field based on user

        Can someone please help me with a client script to achieve the following? I've already tried a couple of different scripts I've found on here (updating to match my details etc...) but none of them seem to work. No errors flagged in the codes, it just
      • What is a a valid JavaScript Domain URI when creating a client-based application using the Zoho API console?

        No idea what this is. Can't see what it is explained anywhere.
      • 5名限定 課題解決型ワークショップイベント Zoho ワークアウト開催のお知らせ (9/25)

        ユーザーの皆さま、こんにちは。Zoho ユーザーコミュニティチームの藤澤です。 9月開催のZoho ワークアウトについてお知らせします。 今回はZoomにて、オンライン開催します。 ▷▷参加登録はこちら:https://us02web.zoom.us/meeting/register/6OSF2Bh6TumsMIlDwaY_PQ ━━━━━━━━━━━━━━━━━━━━━━━━ Zoho ワークアウトとは? Zoho ユーザー同士で交流しながら、サービスに関する疑問や不明点の解消を目的とした「Zoho
      • Zoho Calendar not syncing correctly with personal Google Calendar

        Coming to this forum as Zoho Calendar support team is not responding, any more. For the past 8 weeks, I have been having an issue with Zoho Calendar not syncing with my personal Google Calendar correctly. I subscribed to Zoho Calendar iCal in my personal
      • Introducing Assemblies and Kits in Zoho Inventory

        Hello customers, We’re excited to share a major revamp to Zoho Inventory that brings both clarity and flexibility to your inventory management experience! Presenting Assemblies and Kits We’re thrilled to introduce Assemblies and Kits, which replaces the
      • Customer Parent Account or Sub-Customer Account

        Some of clients as they have 50 to 300 branches, they required separate account statement with outlet name and number; which means we have to open new account for each branch individually. However, the main issue is that, when they make a payment, they
      • need a packing list feature

        In our business, goods listed on an invoice are packed in separate boxes and shipped off. for e.g. an invoice may have 10 items. each item could then be packed in different boxes depending on qty of each item. this packing list is as important as the invoice for purposes of shipping documents.  Request you to add this feature asap.
      • Prevent stripping of custom CSS when creating an email template?

        Anyone have a workaround for this? Zoho really needs to hire new designers - templates are terrible. A custom template has been created, but every time we try to use it, it strips out all the CSS from the head.  IE, we'll define the styles right in the <head> (simple example below) and everything gets stripped (initially, it saves fine, but when you browse away and come back to the template, all the custom css is removed). <style type="text/css"> .footerContent a{display:block !important;} </style>
      • Workdrive 5.0 / API Documentation Workflows

        Hi Zoho, When will the API documentation of the workflows be published? We are interested in using it to trigger manual workflows from an external application. Greetings, Justin
      • How to keep track of bags, cans, drums of inventory?

        We buy and sell products that are packaged in bags 🛍️, cans🥫, drums🛢️, etc. with batch numbers. When we get a shipment of one of the products, how do we track we received (say) 10 cans each of 5L of a product and maybe we received 10 cans of another
      • Zoho Error: This Operation has been restricted. Please contact support-as@zohocorp.com for further details

        Hello There, l tried to verify my domain (florindagoreti.com.br) and its shows this error: This Operation has been restricted. Please contact support-as@zohocorp.com for further details. Screenshot Given Below -  please check what went wrong. Thanks
      • How many ZOHO-Sites does the ZOHO-One Suite allow for?

        The free version of ZOHO-Sites allows for two sites, but it seems that the professional version (which is included in the ZOHO-One Suite) only allows for two websites. Is that correct? How many sites can I have within one ZOHO-One account?
      • Replace Lookup fields ID value with their actual name and adding inormation from subforms

        Hi everyone,  I wanted to see if someone smarter than me has managed to find any solutions to two problems we have. I will explain both below.  To start we are syncing data from Zoho CRM to Zoho Analytics and I will use the Sales Order module when giving
      • Having Trouble Opening The Candidate Portal

        Recently am having trouble opening the Candidate Portal. It keeps loading but cannot display any widgets. Tried Safari, Chrome and Edge. Non of them work. Please solve the problem ASAP.
      • Webhook from Zobot to Zoho Flow fails

        I'm trying to connect from zobot to zoho flow. When testing in zflow, I am receiving all entered data from the connector correctly. The SalesIQ connector's "outputreaction" is {} (is this normal or is there a problem?). But as soon as I try my chat bot
      • Transition from Sole Proprietorship to GmbH (Limited Liability Company) – Best Approach in Zoho Books / Zoho One

        Hello everyone, I am currently operating under a Zoho One plan with a sole proprietorship in Switzerland. As of January 1st, 2026, I will be incorporating a new legal entity – a GmbH (Swiss equivalent of a Limited Liability Company). While the business
      • Best way to display complex Bookings Consultation Descriptions on Zoho Site?

        I am a new user so apologies if this has been asked before. I couldn't find any answers in the forum. We offer 18 complex Consultations to our subscribers. Our current platform lets me put detail on these Consultations thoroughly (200-300 words) during
      • DKIM cannot be enabled for the domain as no verified default selector present

        Hi Support Team, For Domain DKIM record trying to enable status. but showing error "DKIM cannot be enabled for the domain as no verified default selector present" So, please resolve the issue. Thank you.
      • Issue Connecting My Domain to Zoho Sites Despite Purchasing It from Zoho

        Hello, I am facing an issue connecting my domain to my website on Zoho Sites. Details of the issue: I purchased the domain directly from Zoho. I am already using the same domain successfully with Zoho Mail. However, when I try to assign this domain to
      • Insert auto number from main form into subform rows

        Hello. I'm trying to take from my main form "order number" which i have setup as an auto generated number into every line created in my subform. So when a row is created in my subform i want the "order number " from the main form to be inserted automatically.
      • Dark Mode - Font Colors Don't Work

        When editing a document in Dark Mode and selecting font colors, they don't show up on screen.  Viewing/editing the same document in Light Mode shows them just fine.
      • Integrate Bunq with ZOHO Bookes

        We are new users of ZOHO Books, and our bank (BUNQ, in the Netherlands) isn't listed on the bank integrations. Is there a way to handle this?
      • Cliq iOS can't see shared screen

        Hello, I had this morning a video call with a colleague. She is using Cliq Desktop MacOS and wanted to share her screen with me. I'm on iPad. I noticed, while she shared her screen, I could only see her video, but not the shared screen... Does Cliq iOS is able to display shared screen, or is it somewhere else to be found ? Regards
      • Access Denied

        I am iOS Developer and updating our clients project and shifted ZohoDeskPortalCore SDKs from cocoapods to SPM and changed few lines of code but now i am get access denied, the help center app is unavailable. please contact administrator.
      • Using Zoho Desk to support ISMS process

        Hi, I am evaluating using Zoho Desk for security incident management. This seems to be aligned with Zoho Desk purpose as its just another type of incident. However in security incident management, ideally I can link incidents (tickets) with a risk from
      • Bin Locations

        Dear all, I am wondering if someone has the ability to develop the bin locations option for zoho inventory (integrated with zoho books) Regards, Ryan
      • TaxJar vs Avalara

        Hi, I'm evaluating adoption of a sales-tax service for US based business. Anyone else have experience with TaxJar and Zoho Books? I am a Zoho One subscriber so anticipate needing to use Flow to make this work. It seems like Avalara are simply too expensive
      • How to check Leads with no Task (open activity)

        Hi everyone, I was wondering if there’s a way to view leads that don’t have any tasks assigned or open activities linked to them.
      • What can we do on our end to improve the Answer bot answers?

        Hi, I'm using the Answer bot card in the Codeless bot builder. I've input several questions and their answers in the FAQ section to feed the Answer bot. The text is all in French, as this is the language our customers communicate in. I've tried testing
      • Zoho Books Sandbox environment

        Hello. Is there a free sandbox environment for the developers using Zoho Books API? I am working on the Zoho Books add-on and currently not ready to buy a premium service - maybe later when my add-on will start to bring money. Right now I just need a
      • Taxes for EU B2B Transactions

        Currently, ZC doesn't seem to have a procedure for validating VAT numbers of businesses purchasing in another EU state, and removing local VAT is valid.  This is essential for all inter EU B2B trade.
      • How to upload file to Connect using API?

        Hi there. I looked at the API documentation and nowhere did it mention how to use the API method to upload a file even though it is mentioned that it is possible to be done so. Please help.
      • Items Landed Cost and Profit?

        Hello, we recently went live with Zoho Inventory, and I have a question about the Landed Cost feature. The FAQ reads: "Tracking the landed cost helps determine the overall cost incurred in procuring the product. This, in turn, helps you to decide the
      • Group Tax in Service Line Items

        Hi FSM Team! I noticed that when you update a tax in the service line item the group tax is not showing up as an option. Let me know what can be done thank you!
      • Zoho Campaigns - Why do contacts have owners?

        When searching for contacts in Zoho Campaigns I am sometimes caught out when I don't select the filter option "Inactive users". So it appears that I have some contacts missing, until I realise that I need to select that option. Campaigns Support have
      • Next Page