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!


    Zoho Campaigns Resources


      • Desk Community Learning Series


      • Digest


      • Functions


      • Meetups


      • Kbase


      • Resources


      • Glossary


      • Desk Marketplace


      • MVP Corner


      • Word of the Day


      • Ask the Experts


        • 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",

        Zoho CRM Plus Resources

          Zoho Books Resources


            Zoho Subscriptions Resources

              Zoho Projects Resources


                Zoho Sprints Resources


                  Zoho Orchestly Resources


                    Zoho Creator Resources


                      Zoho WorkDrive Resources



                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ






                              ご検討中の方

                                • Recent Topics

                                • Building a form with Categories and multiple sub-categories

                                  Hello, I am completely new to Zoho and the Deluge programming language. I would like to build an easy way to lookup a set of previous orders from my order tracking sheet. What I have done so far is import my Excel order list into Zoho so it shows all
                                • Zoho IP blocked by SpamCop 136.143.188.16

                                  Hello, I am unble to send any single email during the whole time due to the Zoho IP 136.143.188.16 being blolced by SpamCop.net Please help on this. RROR CODE :550 - spamcop.mimecast.org Blocked - see https://www.spamcop.net/bl.shtml?136.143.188.16. -
                                • Can't sign in to Zoho using Google account

                                  Just checking if anyone else has an issue signing into Zoho with a Google account at the moment? (Have tried Zoho Books in the app on mobile and Chrome and Firefox on Windows 10 - doesn't work for the forums either). Error message appears as attache
                                • unable to send message email outgoing blocked 554.5.1.8

                                  Hi good day to you, After migrating to a new hosting, I cannot send outgoing email, with an error message as below : unable to send message email outgoing blocked 554.5.1.8 Please kindly unblock my account, as I am in a rush to use it to work & communicate
                                • Zoho CRM - COQL query failing with no reason

                                  Hi I'm trying to execute a COQL query but it's returning an error. Unfortunately I cannot understand where I'm wrong The query is the following;: URL: POST https://www.zohoapis.com/crm/v2.1/coql Body: { "select_query": "select id,Adjustment,Billing_City,Billing_Code,Billing_State,Billing_Street,Buyer_PO_Number,Delivery_Date,Delivery_Method,Due_Date,Grand_Total,Invoice_
                                • SMTP Authentication error with django backend

                                  Hello I have e zoho mail id info@mindbrewers.in But when i use it for smtp it gives 535 authentication error in django website . EMAIL_USE_SSL = False EMAIL_USE_TLS = True EMAIL_HOST = "smtp.zoho.com" EMAIL_PORT = 587 EMAIL_HOST_USER = "info@mindbrewers.in"
                                • Separate Triggers and Enhanced Information for Zoho One Departments and Groups in Zoho Flow

                                  Dear Zoho Flow Team, I hope this message finds you well. Currently, there seems to be a mix-up between zoho one departments and groups in Zoho Flow, which causes some challenges in handling triggers effectively. For instance, when using the "User added
                                • Zoho Mail Search Engine Sucks

                                  Hello There! I really like all the features of Zoho Mail and I believe is way better than Gmail except for the Search Function. I believe Zoho Mail has a very poor search function, if you misspelled a word in the search box, Zoho Mail won't display any
                                • No recibo correo en en mi bandeja de entrada

                                  Hola, no puedo recibir correos en mi bandeja, tengo una pagina web y puse el correo en un formulario y cuando meto los datos y los envio no me llegan , pero si pongo otra ya sea gmail, outlook si los recibo, tiene que ver con mis dns?
                                • The sending IP (136.143.188.15) is listed on spamrl.com as a source of spam.

                                  Hi, it just two day when i am using zoho mail for my business domain, today i was sending email and found that message "The sending IP (136.143.188.15) is listed on https://spamrl.com as a source of spam" I hope to know how this will affect the delivery
                                • desbloquear cuenta

                                  Buenos dias  Cordial saludo Tengo una cuenta libre en zoho mail asociado a un dominio, pero uno de los usuarios se bloquea el correo porque dice que ha excedido el límite de correo, por favor podrian desbloquearla y como hago para que esta persona debe enviar sus correos sin ningun probleama. Gracias de antemano
                                • Zoho SMTP IP Addresses

                                  We are using Zoho Mail for a domain and need to whitelist some STMP IP from your service for a redirection. You can provide IP address list for Zohomail SMTP servers?
                                • no me llegan los correos a Zoho mail

                                  No puedo recibir correos pero sí enviarlos, ya hice la modificación de MX y la verificación de teléfonos, qué es lo que ocurre? gracias
                                • Emails being duplicated in sent items folder

                                  Since this morning, emails I send are appearing in my sent items twice (it wasn't happening before this morning) This appears to be a bug with zoho mail ... I can't see any other reason why they would appear twice.
                                • Restrict SalesIQ Account Notifications to Admins

                                  Dear Zoho SalesIQ Team, We appreciate the continuous improvements in SalesIQ. However, we have noticed that all users, including employees who do not have admin privileges, receive certain account-related notifications—such as the recent splash screen
                                • Email client fails to connect to IMAP & POP EU Servers for ALL users

                                  For the last couple of days, all users on my account are failing to connect to the Zoho EU mails servers. This is using mobile app on various phones & desktop mail clients on different computers. Everything works fine when using webmail & email is still
                                • Domain Redemption Time

                                  I have a domain that is currently expired and is in the redemption period. I have already paid the redemption fee and renewal fee during the redemption period. However, there is no response and I am still being asked to pay the fees. How long will it
                                • Same name but different email addresses

                                  Hello, I'm having a problem with managing the names of users in my organization, one of the examples in the attached screenshot shows that when i changed an email for one of the users the old email stayed but shows the correct name on top of that it also
                                • Error opening email

                                  I just tried Zoho Mail for the first time and finished setting up my account. However, after the setup, incoming emails show an error message in the email body. Could you please help me? Thank you.
                                • Setting up DKIM in AWS Route53

                                  Hi, AWS is not allowing me to enter the large DKIM value, which ZOHO needs me to setup for DKIM: v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCIr6rqDssUHEehaprZvNqlwBR8kGkQn4+ivpkGWSe+2qxyIBz5OE/AKUgDJLq+IoNYHiLn2hFK+RBbEWIr/5iFdurwclFID7z/QiuKxwIZcmCRq5lFf3xiWIqXwyIRTTr390LMDZdwIgJSISuogtNN/Q5Iv9gkJir/fb3OJxlgEwIDAQAB
                                • Multi Select Between Modules

                                  Hi, I'm not sure if this is possible, but I want to "import" or "mirror" the multi select options from one module to another. For example... I have Module "Clients" with a Multi Select Field of "Enrolled Services" I also have a Module "Services" with
                                • Can send emails but cannot receive them

                                  Hello, I'm currently unable to receive emails but can send them. Checked my domain on the settings page as I thought I might have accidentally deleted a TXT file but it's saying it's valid and no option to fetch what TXT fields to do Please let me know
                                • Recreating Zoho Account with Existing Domain

                                  Dear Zoho Support Team, Currently, I own the domain wassclothing.com, but it appears that someone has already registered this domain in Zoho Mail. As a result, I am unable to create a new Zoho Mail account using this domain. Could you please guide me
                                • Automated Shopify adjustment problem. "An inventory adjustment has been created by the system to set the initial stock from Shopify"

                                  Has anyone noticed issues since the Shopify Sync has been updated recently? If you sync with Shopify, check to see if there are automated adjustments for old products that keep recurring. We have this problem for 6 SKU's that Zoho is doubling the stock
                                • "Unable to scan for viruses.

                                  : Unable to scan for viruses. I've tried uploading it three times, but I keep getting the same error, which prevents me from sending an invoice. I created the PDF myself and am certain it does not contain any viruses. Are there any workarounds available?
                                • Getting an error when trying to connect zoho mail to Make

                                  Hi, I'm trying to send an email via Make Integration. I configured the Server application and set the connection in Make Scenario. When I hit the save button I get an error from Zoho: Invalid Redirect Uri Redirect URI passed does not match with the one
                                • Urgent: Zoho Mail Not Sending or Receiving Emails

                                  Hi Team, I am experiencing an issue with my Zoho Mail account—it is neither sending nor receiving emails. Please investigate and resolve this as soon as possible. Let me know if you need any further details. Thank you!
                                • Zoho ToDo and MS Outlook

                                  Hi, Is there a way to create a Zoho Todo task from Outlook app or web. eg. Reading email in Outlook and need to create a task to reply on a scheduled date. Regards
                                • How to disable clone record for a user?

                                  Hi, I'd like to disable clone records for some of my users in zoho crm. How can I go about doing that? Regards, CRM
                                • Payroll Chart of Accounts Config for Dummies

                                  USA What should my COA look like for one employee, paid via a service (Gusto), no benefits. I pay her wage, associated taxes, and the Gusto monthly fee. I'd like to know the COA account type, any sub accounts, what goes where, any payment splits, etc.
                                • Menu Bar

                                  Hi, Please guide how to change menu bar from vertical to horizontal
                                • Create Ticket ignores a list of "secondaryContacts"

                                  Hi, we're trying to create a ticket, with a contact to be a CC. According to the documentation, it should be a list of IDs in "secondaryContacts". But when the ticket is created, it returns an empty array. Has someone tried it? Thanks for any hint. BTW
                                • Zeptomail 136.143.188.150 blocked by SpamCop

                                  Hi - it looks like this IP is being blocked, resulting in hard bounces unfortunately :( "Reason: uncategorized-bounceMessage: 5.7.1 Service unavailable; Client host [136.143.188.150] blocked using bl.spamcop.net; Blocked - see https://www.spamcop.net/bl.shtml?136.143.188.150
                                • EDIT MAIL DOMAIN

                                  HOW DO I EDIT MY MAIL DOMAIN
                                • On-prem version of Zoho Desk

                                  Is there an on-prem version of Zoho Desk available for enterprise customers if we have additional aspects of security that aren't covered with current legal and data security terms?
                                • Workers unable to submit time logs

                                  I received a phone call and an email from employees saying that they received the same error code. They cannot submit the hours that they worked. The clerk whose email is problematical is not in the office this week and does not have access to her email.
                                • Error 550 - receiving email

                                  Hi, We've been getting messages from three different customers that our email address was bouncing. Our email address is hello[at]meteoorbooks.com. This was the error message they received: The response from the remote server was: 550 5.0.1 Recipient
                                • solicitud cambio de dominio

                                  buenas tardes por favor me pueden ayudar con un cambio de dominio es que al crear un correo corporativo manual y agregue un dominio inscribí el mío pero le anexe letras de mas y no pude seguir con el proceso y no se como hacer para seguir con la configuración
                                • Zoho Desk's ASAP announcement | Time to embrace the enhanced JWT Authentication Mechanism for ASAP | Dec'23

                                  Hi All, We are eager to introduce the enhanced JWT authentication mechanism for accessing your ASAP add-ons. Effective December 25th, 2023, the ASAP's old JWT authentication mechanism will be deprecated. This means that the option to switch to the new
                                • Attach Subform images from Zoho Creator to CRM Module

                                  Good afternoon eveyone. I am having a difficult time trying to find a way to attach a subform image from a creator app to a CRM module. I have tried so many ways that I don't even know which way was on the right track because none of them worked. If anyone
                                • Next Page