Function #41: Sync Associated Subforms!

Function #41: Sync Associated Subforms!



Welcome back everyone!

The last custom function showed how to update a Contact with Product details from it's Related list in Deals. This week, let's look at a function that lets you update subform records in two modules simultaneously when one of them is updated.

Business scenario

Let's look at how subform helps in an education institution that has deployed Zoho CRM. National Public School, Austin (made up, of course!) has set up Zoho CRM and it follows the same relationship pattern of "Students", "Teachers", "Courses", "Timings"(assume that the said names are Modules in the CRM). Let's say there are 10 students, 3 teachers, 6 classes and 8 hours per day. All these are all interlinked.

Sales data is no different. They are often updated in different modules, such as "Contacts", "Deals", "Products", etc. Hence, it becomes necessary to have many-to-many record associations.Subforms in Zoho CRM helps enable association of multiple data records across modules.

The function for this week lets users sync two subforms in the Accounts module, such that if one subform is updated, the other one gets updated too. Let's say there are two branches for a particular organization. Instead of having the entire organization's info in a single Account record, it's smarter to create multiple Accounts for branches. Hence, you need to associate the Main branch with a sub-branch as well as the sub-branches themselves.

In this function, assume 2 Accounts records, A and B, have subforms each. Every time a row (Account B) is added to subform on account A, the function adds a new subform row (Account A) to the subform on Account B. In other words, when a new branch is opened, the records of the main branch and the other branches are updated. In addition, the information about the rest of the branches are updated in the subform under the new branch.

Getting started with the custom function

  1. Go to Setup > Automation > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Auto-Subform updates". Add a description (optional).
  3. Copy the code given below.
  4. Click “Edit arguments”.
  5. Enter the name as “acctId” and select the value as “Account Id”.
  6. Click Save&Execute Script to check the code.
  7. Save the function.

The Code:

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

acctDetails = zoho.crm.getRecordById("Accounts", input.acctId.toLong());
subformDetails = ifnull(acctDetails.get("Related_Accounts"),"");
count = 1;
sub_forms = List();
for each form in subformDetails
{
if ( count == 1)
{
formacctname = form.get("Related_Account").get("name");
formacctId = form.get("Related_Account").get("id");
info "formacctId:" +formacctId ;
formaccttype = ifnull(form.get("Related_Account_Type"),"");
formacctdesc = ifnull(form.get("Description"),"");
subform = Map();
subform.put("Related_Account",input.acctId);
sub_forms.add(subform);
}
count = count + 1;
}
formacctDetails = zoho.crm.getRecordById("Accounts", formacctId.toLong());
formsubformDetails = ifnull(formacctDetails.get("Related_Accounts"),"");
for each forms in formsubformDetails
{
info "formsId:" + forms.get("Related_Account").get("id");
subform1 = map();
subform1.put("Related_Account",forms.get("Related_Account").get("id"));
subform1.put("Related_Account_Type", ifnull(forms.get("Related_Account_Type"),""));
subform1.put("Description",ifnull(forms.get("Description"),""));
sub_forms.add(subform1);
}
parammap = Map();
parammap.put("Related_Accounts",sub_forms);
update = zoho.crm.update("Accounts",formacctId.toLong(),parammap);
info parammap;
info update;

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

Note:

  • The code given above works only for V2 version of Zoho APIs. Please note that the code WILL NOT work for Version 1.0 APIs.
  • Use the function in a Workflow Rule, to automate the process of update.

Found this useful? Try it out and let me know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful. Do check out other custom functions shared in this series here.

See you all next week with another interesting custom function. Ciao!


    • Sticky Posts

    • Function #41: Sync Associated Subforms!

      Welcome back everyone! The last custom function showed how to update a Contact with Product details from it's Related list in Deals. This week, let's look at a function that lets you update subform records in two modules simultaneously when one of them is updated. Business scenario Let's look at how subform helps in an education institution that has deployed Zoho CRM. National Public School, Austin (made up, of course!) has set up Zoho CRM and it follows the same relationship pattern of "Students",
      • Recent Topics

      • Write-Off multiple invoices and tax calculation

        Good evening, I have many invoices which are long overdue and I do not expect them to be paid. I believe I should write them off. I did some tests and I have some questions:  - I cannot find a way to write off several invoices together. How can I do that,
      • How to make a ScreenPop with Customer Information

        Hi, I need open a customer sheet when I receive a call on my pbx. I have a client on my PC that are able to open a web page with a specific url. How can I leave open the Zoho CRM application and search for a customer? Thank you in advance, Mauro
      • Simple Deluge Script

        Hi. I'm brand new to functions but I'm trying to create a script to convert a date field in Meetings to a written format. For example, instead of 02/05/2025 8:00AM, I'd like to convert it to Wednesday, February 5, 8:00 AM. My Date field is the API Name
      • Send emails directly via Cases module

        Greetings all, The ability to send emails from the Cases module, which users have been eagerly anticipating, is now available, just like in the other modules. In Zoho CRM, Cases is a module specifically designed for managing support tickets. If your organization
      • Problem with delivery status in delegate account

        Hello, We have a problem with delivery status in "sent" folder in delegate account. Some messages has no status, some messages has "waiting" status, Some messages are delivered, some messages are delivered wit delay, some are not delivered. Conclusion:
      • Zoho Projects - Custom Objects

        Hello, is there the ability now, or in the near future, to add custom objects to Zoho Projects? The requirement here would be to have the ability to track change requests to a project's budget. The idea here is to have the ability to create a custom Object
      • Create Package From A Picklist

        Dear Zoho, Can it be made possible to create a package from a picklist? The reason our company makes a picklist is for that to become a package Our sales orders have 600-1000 items I hope that makes it clear that it's hard to delete 990 items when we
      • Enable Organization-Wide reCAPTCHA Settings in Zoho Forms

        Hello Zoho Forms Team, We appreciate the existing security options for Zoho Forms, including Google reCAPTCHA v2 (checkbox) and reCAPTCHA v2 (Invisible). However, we have a major usability concern: Current Limitation: Right now, CAPTCHA is a form-specific
      • Store Google reCAPTCHA Site Keys & Secrets in Zoho Forms

        Hello Zoho Forms Team, We appreciate the support for Google reCAPTCHA v2 (checkbox) and reCAPTCHA v2 (Invisible) in Zoho Forms. However, we have a significant usability concern regarding the current implementation. Current Limitation: Every time we want
      • Ho to restrict access to row level to Zoho Analytics users

        Let me explain the scenario we are trying to achieve. We have an online system our team members work with. On it we have 6 users that manage data from different areas (North, South, East and West). We would like to transfer this information to a Zoho
      • Add Support for Google reCAPTCHA v3 in Zoho Forms

        Hello Zoho Forms Team, We appreciate the security measures currently available in Zoho Forms, including Zoho CAPTCHA, Google reCAPTCHA v2 (checkbox), and reCAPTCHA v2 (Invisible). However, we would like to request the addition of support for Google reCAPTCHA
      • Optimize your Knowledge Base for better visibility by allowing search engine crawling and indexing

        All you need to know about no-follow and no-index in KB. What are article crawlability and indexability? Crawlability and indexability are vital for making an article visible and accessible to search engines. When a search engine crawls an article, it
      • Create Dashboard with information pulled from multiple modules?

        I am looking to create an overview dashboard for each account we have within the CRM. This will need to include information from Books, Bookings, Analytics (want to see the graphs). I am new to using Zoho but am trying to help streamline our processes
      • CPQ - Price Rules applying to a prodcuts group

        Hi Zoho Team, In Product configurator is possible to make a rule where you can select "Any product" and set an "aditional condition", thanks to this we can apply a rule to group of products. In case of Price Rules, when I make a Rule for Any product is
      • Zoho Creator Upcoming Updates - December 2024

        Hi all, We're excited to be back with the latest updates and developments on the Creator platform. Here's what we're going over this month: Deluge AI assistance Rapid error messages in Deluge editor QR code & barcode generator Expandable RTF and multi
      • Waterfall Chart

        Hello, I would like to create a waterfall chart on Zoho analytics which shows the movement in changes of budget throughout a few months, on a weekly basis. Should look something like the picture below. Does anyone know how to?
      • Add "Merge by Ticket ID" Option on Ticket Screen

        Dear Zoho Team, We would like to request a new feature for the ticket interface in Zoho Desk. Specifically, we propose adding a button to the ticket screen that allows users to merge the current ticket with another ticket by directly providing the second
      • Problem when condition with lookup field in Zoho Creator

        this is my code: if input.promotions1 != null { info input.promotions1; } And this my result: when i info input.promotion1 (which is a lookup field), it turn back nothing, so what type of this field is? normally i use the condition: if lookup_field ==
      • Dialing Microsoft Teams Phone Service via Zoho CRM

        I am using the VOIP option in Microsoft teams for my office phone system. I was hoping to have a way to dial numbers directly from Zoho CRM, but don't see anything in the Teams Integration or in the Telephony integration that will enable this. Does anyone
      • What's New - January 2025 | Zoho Backstage

        Hi there! As we step into a brand-new year, we’re thrilled to bring you some exciting updates to make event management more enjoyable and efficient. Here’s what we rolled out in January to kick off 2025: Backstage 2.0 now enforced for all users We've
      • Hide/Remove Zia search bar in Mobile app

        How do i hide the Zia Search button " Search across Zoho apps " in the app?
      • Importing Attendees- Excel

        I would like the ability to import attendees using an excel file. Sometimes groups, such as schools have to sign up attendees through there system and then send my organization an excel spreadsheet. Right now there doesn't seem to be a way to import those attendees. If Backstage can export to an excel file it seems like a no-brainer that one would be able to populate that template and import attendees into Backstage.
      • Issue with Attachments in "Email a Thank You Note"

        Greetings, from a few days ago, when registering a new payment and clicking on 'email a thank you not for this payment', Zoho Books does not send anymore my attachments on this email, as before. It is very important to us, once here, we have to send another
      • Zoho CRM Kiosk Upload Files

        Hello all, We are trying out Kiosks at the moment to see where it can fit best in our business. We are still a bit off in the application but lets say we will sort this out. My question is the following - when I create a Kiosk I can add "File Upload"
      • How to add new row in a custom SubForm using Deluge Code in Deal Module

        Hi, Can someone help me with Deluge code to add a new row with data in a custom Subform in a Deal Module. Thanks, Shatakshi Misra
      • CASE Module - email function

        HI there, I dont know if this has been asked or answered before as i couldnt find it on the forums. Issue: when a new case is raised, it goes under case tab and everything is captured. Then how do i send emails to the client who raised case with the details
      • Effortlessly advance through your CRM blueprints by including optional fields in transitions

        Editions: Professional edition and above DCs: All Release plan: This enhancement is being released in a phased manner to customers. It will soon be available to all users. [Updated on 5 Sep 2024] This enhancement has been released to all users in all
      • Zoho CRM - Conditional Assessment for Blueprint Automatic Transition

        Hi, Currently, in Zoho CRM’s Blueprint process, the Automatic Transition feature does not allow for conditional assessments before execution. This limitation significantly impacts workflows where a transition should only occur when certain predefined
      • How can you re-push non failed submission through the integrations again?

        Hi, I can see there is an option the 'Re-push' failed integration submissions from Zoho Forms. Is there a way to do this for all submissions? We've just re-built an integration so things go into different fields and we would like to re-push everything
      • List of API for report

        Can I have list of API for Reporting ? Like this API : https://www.zohoapis.com/books/v3/reports/customerbalances?organization_id={{Organization.Organization_ID}}&accept=pdf
      • How to add row numbers to Subform?

        How to I auto row number rows of a subform in CRM?
      • Zoho Books | Product Updates | January 2025

        Hello users, Now that January is over, here are some exciting updates to make this new year even better. We’re back with new features and enhancements in Zoho Books, including comparing fields as criteria in workflow rules and a custom SMTP integration.
      • Python Code: Calling "Deals" API results in 404 Error.

        Good evening, I wrote a small python code to scrape the data from a selected record and then copy the information I need into another website. We have renamed the "Deals" module to "Opportunities", however the API name remains as "Deals" which is fine.
      • How to change contact record owner to its creator?

        When I convert a lead record into a contact and a deal then a the contact record will have User AAAA as record owner, and the contact record will have User XXXX as the record creator. I don't have any workflow rules in Contact module. I use the blueprint
      • How to merge duplicate products?

        merge duplicate products
      • Function to update field in CRM Meetings from Bookings Appointment Status

        Hello, We're creating some reporting in Zoho Analytics using data from CRM and Bookings. Unfortunately it looks like when Bookings Appointments are carried over to CRM Meetings, the Bookings Appointment Status is not recorded in CRM Meetings. We would
      • Unresponsiveness in Zoho Cliq

        Time of post: 6:56 am PDT, 19 July 2023 Dear Cliq users, We have encountered an unprecedented issue in our messaging servers. The details of the issue are as follows: Impacted users : 1/4th of users in US DC (users who access cliq services through cliq.zoho.com)
      • Importing Tasks : Where is the flexible work hours field ?

        I need to be able to import a years worth of flexible hours for our part time workers, but I can't find what field to import to. When I do an export, there is nothing that signifies Standard/Flexible and whenever I import it automatically sets it to Standard...
      • Zoho CRM Calendar View

        Hello Zoho team, We need desperately a calendar view next to list, kandan and other views. I think it should be easy to implement as you already have the logic from Projects and also from Kanban View in CRM. In calendar view when we set it up - we choose
      • Attendance Over-writing of Leave

        Hello Zoho, Currently if an employee comes to work while they have applied for leave, the system considers them as "on leave". Shouldn't the employee be marked as "present". Give it a thought
      • Next Page