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

        • MA 2.0 Email Footer

          Good day, I recently went through the nightmare of upgrading from MA 1.0 to MA 2.0 and continue to experience more problems or missing features and settings. In this particular case, I am trying to find where and how to edit the Email Footer in MA 2.0.
        • Is it possible to hide self view in Zoho Meetings

          Hi - I want to hide my camera view when conducting meetings in Zoho Meetings.  Most of my meetings are one to one with clients & I prefer to focus on them them on the screen? I've searched and cant find any options for this? Thanks Ro
        • Auto-sync field of lookup value

          This feature has been requested many times in the discussion Field of Lookup Announcement and this post aims to track it separately. At the moment the value of a 'field of lookup' is a snapshot but once the parent lookup field is updated the values diverge.
        • Zoho CRM Functions 53: Automatically name your Deals during lead conversion.

          Welcome back everyone! Last week's function was about automatically updating the recent Event date in the Accounts module. This week, it's going to be about automatically giving a custom Deal name whenever a lead is converted. Business scenario Deals are the most important records in CRM. After successful prospecting, the sales cycle is followed by deal creation, follow-up, and its subsequent closure. Being a critical function of your sales cycle, it's good to follow certain best practices. One such
        • Is there a notification API when a new note is addeding

          Trying to push to Cliq, or email notification when there's a new note added in module. How to implement this?
        • Update Client Record based on creation of custom module record

          Hi! Hoping for someone's help with this one. I have a custom module called 'Agreement History. Whenever a deal is won, it creates a new record in this module with associated 'Products' and 'Clients' to track rental history and contracts. What I'm trying
        • Zoho Workdrive Fixed View or Sort Settings for External Links

          Hi , For the folder links we shared via an external link, it would be great if we could set the view and sort options that the external user will see when accessing the file through the link. Thanks to everyone.
        • Zoho Creator Upcoming Updates - March 2025

          Hello everyone, We hope you’ve had the chance to explore Release Projection 1 for 2025! This month, we’re keeping up the momentum by bringing even more powerful features and enhancements to Zoho Creator. Here's what you can expect in March: App menu builder
        • Workflows for Timesheet

          Good day, Any way to have timesheet as triggers? I looked into Zoho Flow and into Zoho Project automation but no where can I have timesheet as a trigger. Basically, I would like to trigger something upon timesheet approval. Right now, the only way to
        • Duplicate Contact Records in Zoho CRM

          Hi team, Has anyone experienced an issue in Zoho CRM where contact records are suddenly being duplicated? I noticed today that some of our existing records appear to have been added again as new contacts earlier this morning. Appreciate any insights or
        • Not receiving New Ticket Emails

          Hello! The company I work for uses the Zoho ticketing system, however, I've noticed I'm not receiving email notifications when new tickets are published. I have admin rights to see these tickets on Zoho Desk and respond to them, but am not receiving the
        • Using Zoho One to manage two (or more) businesses

          We are one company that operates two business, a scenario that Zoho One doesn't really seem to handle very well, and one which I can't imagine is at all unique to us! (It is basically designed to facilitate branding and use for one business only per subscription).
        • VOORRAADTELLING - Kom er met me verstand niet helemaal bij.....

          Beste Zoho One, Wij hebben mega veel producten van zoho maar dit begrijp ik werkelijk niet. Wij gebruiken voornamerlijk ZOHO FSM met ZOHO INVENTORY omdat wij in service en onderhoud zitten voor elketrische laadstations voor auto's Alle medewerkers van
        • Success message - Warning message

          We already have the "success message". The alert does not work in the report action; a "warning message" (with red color) would be ideal. Additionally, we should be able to set the duration which the message stays before it fades out, as it is currently
        • books+POS+ tap to pay+ stripe

          So in the UK we now have tap to pay with stripe. So we can use the stripe app as a POS terminal. Brilliant news. Can we hope that the Books App might add this feature ASAP. It would be great to have one system rather than using the not very good Square
        • Instantly refine your CRM dashboard using Filters and download underlying data – all in a few clicks!

          Hello everyone, Imagine you’re a sales manager overseeing multiple product lines across different regions. You're viewing your sales dashboard in Zoho CRM, which gives a powerful overview, but you often need to drill down to see how a specific product
        • Custom Related List anchor tag with tel protocol

          The following code worked great for about a year to create clickable tel and mailto links in a related list in the Deals module. Just this morning, it started displaying the HTML as text. For example: <a href='tel:8882490100'>8882490100</a> Zoho support
        • How to create a contract using Zoho Contracts API and have the systemStatus directly assigned as "Active"?

          Hi Team, How do I create a contract using Zoho Contracts API and have the systemStatus directly assigned as "Active" instead of "Draft"? Currently, I'm able to create a contract but the systemStatus is "draft". Kindly help.
        • Python - code studio

          Hi, I see the code studio is "coming soon". We have some files that will require some more complex transformation, is this feature far off? It appears to have been released in Zoho Analytics already
        • Syncing with Google calendar, Tasks and Events

          Is it possible to sync Zoho CRM calendar, task and events with Google Calendar's tasks and events. With the increasing adoption by many major tool suppliers to sync seamlessly with Google's offerings (for instance I use the excellent Any.do task planning
        • Filtert products by multi select custom field

          Hello, this is seems like a must addition, why it can not be done now?
        • CRM quotes and sub forms.

          Recently upgraded to Enterprise CRM - now some added hopes/questions * In a subform in quotes, if I add a "Percent" field, called Overage for instance. I would expect it to allow me to enter a percent like "10%" and carry the percent forward to formulas
        • Problem with WorkDrive and Vivo X200 Pro

          Hey there, after a long odyssey of searching for a new phone, several issues and defects with a phone from another brand and many reinstallations and transfers I stuck to the Vivo X200 Pro. So far, so great. Only thing not working is the Zoho WorkDrive,
        • Cambiar nombre de usuario

          Hola. Tengo una cuenta en zoho, por ejemplo Minombre @ midominio.es Y quiero cambiarlo a Miotronombre @ midominio.es Se puede cambiar??? Con la cuenta gratuita de zoho, cuantos nombres puedo tener en un dominio??? Gracias y buen dia
        • Can't add company logo and favicon as a superadmin

          I am logged in as the superadmin but can't add company logo and favicon - the fields are greyed out. Any idea as to what the problem could be?
        • Inquiry regarding B2B website through Zoho Commerce

          We are looking to build an online B2B customer portal for Consumer Goods primarily for order placement, with an e-commerce-style layout. Additionally, we would like to offer our customers features such as: 1.Viewing past orders and order updates 2.Accessing
        • ASAP Chrome Extension not loading

          We have ASAP enabled in Zoho Desk. I installed the ASAP Chrome Extension (Windows 10), but when I click the extension button while on our site, it never fully loads. I just get what's shown below.
        • Why is the Zoho portal not mobile friendly?

          I just got started with the portal and im sort of shocked how it looks. I already filled a hint/complaint about this. On the website you see a wonderful site with a modern design. Yet in real life its a mid 2000 look and feel. One major issue i see thats
        • New Asap Widget How to update my code

          I know you're still working on updating the documentation for calling the Asap Widget, the existing documentation is no longer valid. In the old 1.0 version I was able to do many things programmatically in javascript. I could open an article directly
        • Condition in templates

          Is it possible for me to add merge field conditionally in my templates. For example Dear ${Leads.Gender == "Male" ? "Sir" : "Ma"},
        • How to Dynamicaly display image in the Detailed View Report ?

          I have an "Add Employee" form that includes an image field for uploading an employee's profile picture from their local computer. In the "Apply Leave" form, I also have an image field where I want the employee's profile picture to be auto-populated based
        • Zoho Flow Custom Function to Register Sale in Zoho Thrive

          Hi Thrive team, I want to create a custom function which sends purchase information back into Thrive for Affiliate commission. I'm stuck on how to setup the connection, specifically creating an OAuth connection through https://api-console.zoho.eu/ Please
        • Sending User-centric reports to all users

          I would like to automate an e-mail report to all users that sends them a weekly e-mail listing their open Potentials.  I've created a Report that uses the ${CURRENTUSER} criterion and scheduled the report to send to several users, but they all receive
        • How do I add new line and format text in zoho desk ticket?

          I am generating a ticket via API and looking to update "description" field of ticket whenever I need. Is there a document where I can find supported formatting for description field on a ticket.  I need to find: Adding a new line and adding bold text,
        • Automation #6 - Prevent Re-opening of Closed Tickets

          This is a monthly series where we pick some common use cases that have been either discussed or most asked about in our community and explain how they can be achieved using one of the automation capabilities in Zoho Desk. Typically when a customer submits
        • Feature Request - Insert URL Links in Folders

          I would love to see the ability to create simple URL links with titles in WorkDrive. or perhaps a WorkDrive extension to allow it. Example use case: A team is working on a project and there is project folder in WordDrive. The team uses LucidChart to create a drawing/s for the project. The team member could create a link to the LucidChart drawing/s and allow WordDrive to truly be a repository for ALL the project documents, even those outside of WorkDrive. A folder is dedicated to a CRM account. A
        • ZOHO DESK ヘルプセンターの言語選択メニューの表示方法

          ZOHO DESK のヘルプセンターを構築し、多言語化設定をしました。 顧客のヘルプセンター画面右上に言語選択メニューが表示されないため、弊社の契約先会社に問い合わせましたが、「通常は多言語化をオンにすると表示するためCSS を触り過ぎではないか」 という指摘のみでした。 試行中ですが表示できません。 何か要因となる情報をお持ちの方がいましたらご教授いただけますと幸いです。 ↓の赤枠を表示したいのですが、表示できません。
        • How to reply to thread via API

          We have built a webapp for our customers that uses the Zoho Desk API to enable each customer to view their full list of tickets, view individual tickets and raise new tickets. The Zoho Desk API doesn't have the ability to reply to a ticket/thread. Replies
        • Email Builder Editor is not functioning or loading correctly

          Email editor function is not working or loading correctly in any template, new or old. Cleared my cache, restarted browser, problem unchanged.
        • Create Tasklist with Tasklist Template using API v3

          In the old API, we could mention the parameter 'task_template_id' when creating a tasklist via API to apply a tasklist template: https://www.zoho.com/projects/help/rest-api/tasklists-api.html#create-tasklist In API v3 there does not seem to be a way to
        • Next Page