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

      • 2024: A Year of Transformation with Zoho Forms

        As we close the curtain on another exciting year, it’s time to reflect on the strides Zoho Forms has taken in 2024. From empowering businesses with advanced tools to simplifying workflows and enhancing user experiences, our updates this year were all
      • Stop selling out of stock Items.

        Hi I have been using Zohobooks for a around 8 month now. I am not involved in selling process but my staff cant stop selling product which they do not hold in stock, this is a big headache for me as physical count never matches what is shown on the books. 
      • Bigin API Token Request ("invalid_client")

        Hi people, I tried to connect to the API without success, I've read all of the documentation multiple time and tried just about everything. I tried to do it with Python Request module and with Postman, passing the information through both the URL parameter
      • Customer Happiness not clickable when using API

        Is there a way to automatically add the Customer Feedback links when generating email drafts via the API? Currently, the feedback links are only added when generating an email draft using the UI. I tried using the endpoint described in https://desk.zoho.com/DeskAPIDocument#CustomerFeedback#CustomerFeedback_Getthecustomerfeedbackplaceholderlink
      • Restricting Calendar View to Working Hours

        Hi: I'm trying to implement a calendar which displays all of my customer appointments.  Currently, the calendar shows all 24 hours of the day.  Is there a way to restrict the hours to simply the times my business is open? Thanks!
      • Send To Zoho Sign not Showing

        The button send to Zoho sign is not showing on my Zoho CRM . Is there additional steps I need to take after installing Zoho Sign to CRM ?
      • How to Get An Image's URL once it's uploaded to library?

        I manage to find URLs to the images I uploaded to my library, but after a day, it seems the links stop working like its only temporary. Where can I find the ACTUAL solid URL for my images that I upload to my Library so I can use them for my custom template / HTML coded template? Thanks, Mac
      • 【Zoho CRM】インポート機能のアップデート:既存データへのタグ追加が可能に!

        ユーザーの皆さま、こんにちは。コミュニティチームの藤澤です。 今回は「Zoho CRM アップデート情報」の中のインポート機能のアップデートをご紹介します。 Zoho CRMのタグは、データを効率的に分類、認識するためのラベルです。 タグ付けは次の3つの方法で行えます: 個別タグ付け:少数のデータを手動でタグ付け 自動化:特定のタイミングで繰り返しタグ付け 一括更新:インポート機能でタグを追加または更新 今回のアップデートでは、インポート時に既存のタグを残したまま、新しいタグの追加、既存タグを置き換えできるようになりました。
      • mail

        Frequent sending of this email, what does this mean? How to solve it
      • Issues with Calendar .ics Files Attached in Customer Email Notifications

        Hello, Thank you for recently adding .ics files as attachments in confirmation emails generated by Zoho Bookings; however, it seems that there are some issues with the new feature, particularly in the email notifications sent to customers: If a booking
      • Bluerprints: How to connect the created record back?

        I've a blueprint which creates another record as part of an 'After' transition. But the two records don't seem to be linked together. If it's not automatic - how do I get the created record ID to link it to the original record? Thanks!
      • Populate a Related List Item based on a Stage

        I would like to know if I can populate a CLOSED DEAL section in a contact that populates only when a Deal (something in the Deal Module) is listed as Closed - Won. I'd like another section that is just called deals, which shows me all other deals that
      • Being able to draw inside a module ?

        I was wondering if anyone know of a solution for this request. We would like to be able to draw directly from one module in the CRM and have it attached to that record. Here is an example. Paul would go to the customer once he as done the measuring, he
      • Holidays

        Hi; For defining Holidays, you need to add logic to handle the year as well as the month & day. We need to be able to enter Holidays for the next year. I need to add a holiday for January 2, 2017, but I can't until January 1st, which is a Sunday and we
      • Delete a department or category

        How do I delete a Department?  Also, how do I delete a Category? This is pretty basic stuff here and it's impossible to find.
      • Remove or hide default views

        I'm looking to only have the views pertinent to my organization.  Is there a way to show only my custom views (or separate them to a different area or something)? If not, this should be a feature as switching from Zendesk we had this option...
      • Analytics Module: Can you move items from one dashboard to another?

        Is there a way to move items from one dashboard to another? I want to rearrange my dashboard now that I know what i'm doing but i don't want to remake my various widgets? Edit: Hey Zoho, This would be a good feature: to be able to move/copy widgets to
      • Introducing Record Summary: smarter insights at your fingertips

        Hello everyone, Building on the recent launch of Zoho's in-house Zia Large Language Model (Zia LLM)—a major milestone in Zoho CRM’s AI capabilities—we’re excited to introduce the Record Summary feature. This powerful addition makes use of Zia LLM to simplify
      • Suppress "spreadsheet will not be saved" message on published sheet

        I have published a sheet and have one column on that sheet that the user can edit (a dropdown picklist where the user can select the status for each line). Is there a way to suppress the Zoho Sheet message "Any changes made to this published spreadsheet
      • Missing "Email Authentication" tab

        Backstage is alerting users about "Unauthenticated Domains" with a large prompt in the backend. It adds a link to learn more. On this tutorial page, it shows where to find the "Email Authentication" tab in this screenshot. However, in our Backstage, that
      • Show item Cost value on Item screen

        The Item screen shows Accounting Stock and Physical Stock. It would be very helpful if value information could be displayed here as well, for instance Cost Price. Currently, to find the Cost Price (as used for inventory valuations) from inside the item
      • Integration with Moodle

        Greetings, I hope find all doing well and safe. I've recently returned to using Zoho Flow after a break and was hoping to connect my WooCommerce store with Moodle, the world's most widely used learning management system. My goal was to automatically enroll
      • How to Record Loan with interest

        I have received loans from friend he give me like 2 loans so far one is one year repayment and one short, how to properly record his payment, and repayment and give him statement  for each loan he give me 
      • Task status - completed - other options

        I have a dumb question I know i can make custom statuses for the tasks - but is there anyway to make additional "completed" statuses like for instance if i have a task "call back customer" and i leave a vm for them to call back marking it "completed -
      • Task module and related-to field

        In modules other than the Task Module I can add several lookup fields to provide a variety of relationships. In the Task module lookup fields are not available. There is only one "related to" field which I want to use for Company. But I want to relate
      • Add Lookup Field in Tasks Module

        Hello, I have a need to add a Lookup field in addition to the ones that are already there in the Tasks module. I've seen this thread and so understand that the reason lookup fields may not be part of it is that there are already links to the tables (https://help.zoho.com/portal/en/community/topic/custom-fields-on-task-module).
      • migrating from Zoho Invoices (CRM) to Zoho Books

        Good day, I was wondering if there was a easy way to migrate all the quotes and invoices from Zoho Invoices CRM to Zoho Books. We plan to move to using Zoho Books in a few weeks and would like to have all the quotes and invoices from the past 3 years
      • Zoho MA and Custom Module

        I am trying to create a sync between Markting Automation and Zoho CRM. I am mapping a custom module from the CRM. The custom module has email field mobile phone field However I cannot finish the integration since the system keeps asking me for email or
      • When is partial reimbursement going to be launched?

        Hi there. I saw somewhere that the partial reimbursement feature is in the work. What is the update and ETA of that? Our clients and prospects have been asking us and we agree that that is an important feature to have.
      • Year-End Wrap: Declutter Your Inbox Using Email Filters

        Ping!—an email drops in. And another. And another! It's finally that time of the year when your inbox will be bursting with messages from team members, clients, and marketing agents, leaving you feeling overwhelmed and distracted. Sounds familiar? Now
      • Unified Notes View For Seamless Collaboration

        To facilitate better coordination among different departments and team members, the notes added to a record can now be accessed in all its associated records. With this, team members, from customer service representatives to field technicians, can easily
      • Q4 Europe In-person Zoho User Group Meetup: Streamlining Your Business Processes & Introduction to Zoho CRM for Everyone

        Hello Zoho Community, We are excited to announce our upcoming Zoho User Group meetup in Europe! This session is designed to help you streamline your business processes using Zoho CRM, with a special focus on enhancing customer interactions and leveraging
      • Formula fields - Request for dynamic recalculation / proper implementation

        Hi Guys, I have a big problem with Zoho formula fields. They don't recalculate each time the record is viewed - only when a record is edited. Formula fields should be updated dynamically each time a record is retrieved. As an example: I have a formula
      • Items attribute questions

        Many of my items have attributes, such as size and color. How can I add new fields to the "New Items" screen to capture that in my Purchase Orders, Items, and Sales Order pages? I only see these attribute fields when adding an Item Group. Also, on the
      • Organize and Track Phases with Phase Custom Views

        Phase Custom Views let you filter and display phases based on specific criteria. This helps you focus on what’s most relevant for you and your team. Filter phases using criteria such as budget, status, and more. Share views with specific users or teams
      • Record Asset Received as Payment

        How exactly would you account for this in books? For example, I receive a mini computer for a review and I get to keep it after the video is published. Would debit my normal asset account (e.g. Computers) and credit an income account (e.g. Other Income).
      • Invoice Line Item Report

        Is it possible to run an 'Invoice Line Item Report'? The 'Invoice Details Report' shows one row per invoice. I would like one row per Invoice Line Item.
      • Transform Your Customer Support with AI-Powered Chatbots in Zoho SalesIQ

        Ever wondered how some companies seem to have superhuman customer support? Let's uncover their secret! In the digital age, customer expectations are skyrocketing. Did you know that according to McKinsey, 75% of consumers expect a response within five
      • Progressive Invoicing

        Progressing invoicing is needed for many industries. It would be great to see it implemented into Zoho Books as well. Set up and send progress invoices in QuickBooks Desktop (intuit.com)
      • Client Script - mapping data from different module

        Dear ZOHO Team Firstly I need to describe the need - I need to have data from Contacts module based on lookup field - the 5 map limit is not enough for me because I have almost 20 fields to copy So I have decided to make a Customer Script - and from unknown
      • Next Page