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

        • Free user licenses across all Portal user types

          Greetings everyone, We're here with some exciting and extensive changes to the availability of free user licenses in CRM Portals. This update provides users with access to all Portal user types for free to help them diversify their user licenses and explore
        • How to easy change layout in existing records in Deals?

          Hello, So far i have used only 1 layout in Deals. I have about 1000 records. Now i want to make new layout. So i have 2 layouts: Layout Old (1000 records) Layout New (0 records) How to easy change layout from Layout Old into Layout New for existing records?
        • What is the Desk API?

          I'm trying to fetch a lookup field data from desk to our creator application and it doesn't work. I'm guessing that my search parameter is wrong? On my trial function fetch if I use these: tickets = invokeurl [ url :"https://desk.zoho.com/api/v1/tickets/351081000145244764"
        • Changing Color Theme of Guided Conversations

          Hello, We have recently added Guided Conversations to one of our websites, but I am wondering if there is a way to customize the color scheme so it matches the appearance of the website? Thank you in advance!
        • Length of Call

          Whenever we place a call from the CRM and we click to log it, the duration / length is not automatically populated. Can you set this up to occur? Thanks!
        • Tip #10: Automatically add tags to Zoho CRM records using form responses

          You may be using tags to filter records, create reports based on specific tags, or let your sales team to know which clients to give priority to. Don't skip tagging for the crm records added via forms. The tags can be set to be automatically captured during the form submission. How it works When you set up a configuration to push form entries into CRM, you can add a tag to them automatically. The tag value can vary based on the respondent's input (captured using form fields), or you can include a
        • CRM x WorkDrive: File storage for new CRM signups is now powered by WorkDrive

          Availability Editions: All DCs: All Release plan: Released for new signups in all DCs. It will be enabled for existing users in a phased manner in the upcoming months. Help documentation: Documents in Zoho CRM Manage folders in Documents tab Manage files
        • Using AVG in SQL Query

          My current SQL Query is: SELECT "Client Info", avg("Revenue") FROM "Funded Deals" GROUP BY "Client Info" The current table that this is creating: Client Info avg(Revenue) Previous 4175 1st - New 3411 1st - Old 3013 Renew 3069 While this works as I had
        • Pay Contractor Timesheets

          I have contractors that fill out a timesheet. Each hour must be assigned to a current client. I need the easiest way to get the contracts paid. They are paid on an hourly bases. How can this be done?
        • OAuth with Bubble.io API Connector does not work although it is working in Postman

          Hi, I am new to API programming but have successfully connected Google and Asana with the Bubble.io API connector. Also I have setup Postman and can access Zoho APIs successfully e.g. Projects. Scope used is: ZohoProjects.tasks.CREATE ZohoProjects.tasks.READ
        • How to Parse XML Data Returned by API?

          I have several APIs integrated with my CRM and they work great. I am having some trouble though parsing data out of a large string/array in Funtions? I need to be able to pull the DeviceId and the WebSiteDeviceName from each PanelDevice. I would appreciate
        • Foreign Currency Bank Account

          I have a bank account in USD zero balance but when i run the bank ledger in my company currency in AED it was shown small balance 1.31 AED , how to make it zero also ,Thanks
        • How do you handle existing customers/contacts?

          Hi, We just integrated MA 2.0 with our CRM and we chose to only import our existing customers contacts. In MA they are all "Raw leads" by default and we would like to mass update these to a stage called "already customers" but the last default stage "Sales
        • Quick editing of fields in a report view...

          I've created a report that unites my advertiser accounts with corresponding contact accounts (which are not a subset of Adv. accounts, contacts are their own section). I want to know if there is a way to edit certain fields while viewing my report so
        • Notes from Custom Modules linked to Account Modules

          The way our ZOHO CRM is set up at the moment, whenever a note is entered under a Task or Event the note is visible under both the Task or Event as well as in the notes section under the Account the Task or Event is associated or related to. I have a couple
        • UI / UX Suggestion: Allow Users to Set Colors of Flow Steps

          For those of us who set up complex Flows, it would be nice to be able to color-code different paths / branches for easier future interpretation or troubleshooting. This could take a variety of forms, either highlighting the textual name of the step or
        • Storage Space Issue

          I made a few Header templates in the CRM email that adds some fields ( 2 fields to be exact ) to the subject line, however I ran out of "storage Space" when I need to add it to 3 more members of my team. How do I solve this ? If I need to upgrade , which
        • Server responds internal server error when requesting token

          I am trying to request for token through this url https://accounts.zoho.com/oauth/v2/token I use postman to do this, but everytime I send a request it gives me a 500 response with no messages in it. Below is the screenshot of what i am trying to do. PLease
        • How do I add page breaks to Sales Order templates?

          I would like our Terms and Conditions to start on a new page of the resulting PDF. How do I do this? I tried adding <div style="break-after:page"></div>, but this did not work.
        • Task Timer is missing

          Hi, new here to Zoho... just discovered it yesterday and it looks like a really excellent application!! I signed up but seem to have actually lost some functionality since I did ?!  The handy little way to update your timesheets by mousing over the task and clicking on the green clock is no longer there for me.  I am talking about what is described in this post: http://forums.zoho.com/forumHome.do?forumGroupId=2266000000002001&forumTopicId=2266000000027532# Now the green clock icon does not appear. 
        • Chronicles of 2024: The Year in Retrospect

          As we close out 2024, let’s take a moment to highlight the new features and updates that have enhanced Zoho Invoice in 2024. Among the exciting enhancements, we have launched a new AI-powered chatbot designed to assist you in understanding the app's features
        • Zoho CRM v2.1 deprecation or sunset plans ?

          Hi Team Wanted to know if there is any plan to deprecate v2.1 CRM apis https://www.zoho.com/crm/developer/docs/api/v2.1/ and if yes by when
        • Hide recent projects section?

          Is there a way to hide the recent projects section? It's not that useful to us and never gets looked at, but takes up valuable screen real estate. Can't see an option or any button to close it. Can we do this? If not can it be added? Chris.                  
        • project profitability

          I would love to be able to see my costs for non-billable tasks without that impacting my revenue budget. My project budget type is based on project and my billing method is based on staff hours. if I turn on the option to include non-billable hours in
        • Move data from any fields or upload files to the attachment section in Deluge.

          LeadId = 4857358000014515001; resp = zoho.crm.getRecordById("Leads",LeadId); file = resp.get("Upload_Test"); filelist = List(); if(file != null) { file_Id = resp.get("Upload_Test").get(0).get("file_Id"); getFile = invokeurl [ url :"https://www.zohoapis.com/crm/v7/files?id="
        • Log a Call Function

          First, thank you for implementing the Log a Call function. It's been a frequent request on our team before we can adopt Zoho CRM, and this helps remove that. However, one small detail: the reason people wanted Log a Call was to quickly log a call's activity with the minimum effort possible. With the structure of the new Log a Call function, you have required several fields that are unnecessary for most people and that significantly slow down salespeople or CSRs in logging calls. Could you please
        • How to shortlist a lead's open tasks in ascending or descending order, close all open tasks from oldest to newest, and create new tasks using Deluge?

          //LeadId = 4857358000014515001; optionalMp = Map(); optionalMp.put("sort_by","Due_Date"); optionalMp.put("sort_order","asc"); related_tasks = zoho.crm.getRelatedRecords("Tasks","Leads",LeadId,1,200,optionalMp); for each task in related_tasks { // info
        • Rate Limiting in Zoho Flow (OpenAI API)

          Hi Everyone, We are facing some issues when using Zoho Flow as we have a deluge script running which is making external calls to OpenAI endpoint. Sometimes the response takes more than 30 seconds meaning the script will timeout. We want to implement a
        • Does Client Script work on Zoho CRM Portal?

          Hi ! I create a new module to use at customer portal. But Client Script looks not work. Please help me clarify, thank you!
        • Kaizen #124 - Manipulating Subform using Zoho CRM APIs

          Hello everyone! Welcome back to another post in our Kaizen series. In this post, we will discuss how to manipulate the Subform data using Zoho CRM APIs. Subforms A Subform is a data section embedded in the primary form to collect details related to the
        • Option to Disable Download for Documents Shared via Permalink

          Dear Zoho Writer Team, Currently, when sharing a Writer document using the regular permalink (Collaborators with external users), there is no option to restrict the ability to download the document. While the external share link allows such restrictions,
        • Cross-Data Center Collaboration and / Or allowing users to choose DC

          Dear Zoho Cliq Support Team, We are writing to request a significant enhancement to Zoho Cliq that would greatly benefit our geographically dispersed development team. Current Challenge: Currently, Zoho Cliq automatically routes users to specific data
        • Option to Disable Automatic Email Notifications in Zoho Writer

          Dear Zoho Writer Team, In Google Docs, there is an option to disable email notifications when granting access to a document. This feature allows us to share the document's link manually through our email instead of relying on the automatic notification
        • not able to accept the Invitation

          not able to accept the Invitation
        • Credit note

          By mistake I issued credit note in Jan 2025 for the invoice related to Dec 2024. Now I want to delete this credit note but anable to do so. Need help in this
        • Schedule Zoho CRM reports only on Business Days

          Hello, Is it possible to schedule reports only on business days ? We currently get daily sales reports on weekend which has no value since the sales team doesn't work on weekends. Thanks
        • the custom domain forwards by default to the old career site / how to switch it off??

          dear friends, how to switch off the old version of the career site?? The set up custom domain forwards directly to the old site, so that I cant publish it... Any ideas? Thank you! KR, Victoria
        • Announcing a significant enhancement for Zia Presentation: Personalize the data and distribution of your sales deck

          Dear Customers, We hope you're well! There are two aspects to being a salesperson: Selling and reporting. While the former is the job itself, the latter helps salespeople evaluate their performance from time to time. This evaluation doesn't just help
        • Client script: Can not choose a date field for an onChange field event

          Hi Zoho Team Why can't I choose one of my date fields to trigger an onChange event? Is this a client script limitation, or something wrong with my instance? If it is a limitation, is this mentioned in the documentation anywhere? Thanks. Marcus
        • How I can add customized Invoice

          Hi, I wanna use a customized Invoice, how i can add that
        • Next Page