Function #49: Changing Ownership of Multiple Related Records concurrently!

Function #49: Changing Ownership of Multiple Related Records concurrently!

Welcome back everyone!

Last week's function was about tracking refunds and adjusting the sales executive's revenue in Zoho CRM. This week, it's going to be about simultaneously changing the ownership of a record across multiple modules when it is changed in a single module.

Business scenario

Each of us have our strengths and weaknesses. Someone skilled in sales might not necessarily be better in management. It goes to show that in order to successfully run an enterprise, you need an amalgamation of various different talents that work together. Marketing, Sales, Negotiation, Support, Development, etc. All of them have their roles cut out clearly.

As such, lets say there's a guy from the Sales team who takes care of the leads and converting them into deals. Now, that guy has a lot of work to do in converting the lead. Assigning tasks, events, scheduling calls, emails, cases, quotes, purchase orders, etc. He might have to lay the groundwork for the guy who takes care of the negotiation part after the lead is converted. The initial owner of the deal and all the related records with the deal is the Sales guy, but when converted into a deal, shouldn't the ownership change for all of the records? But guess what, changing the deal ownership doesn't change the rest.

But we do have a workaround as you've guessed, since we explained things this far. You can use a function to transfer the ownership for all of the records simultaneously. And this works best when the function is created within a Workflow rule, which can be set to trigger "This rule will be executed when the field Leads Owner is updated to meet the condition(if any)." And there you have it.

Getting started with the function

  1. Go to Setup > Automation > Workflow Rules.
  2. Click '+ Create Rule'.
  3. Select the Module for which this custom function has to be added and give it a name and a description(optional).
  4. Select "On a record action".
  5. Select "Field Update" and Select the checkbox "Repeat this workflow whenever a record is edited".
  6. Select "Deal Owner" and click Next.
  7. Select "All Records" for the Condition.
  8. Choose "Function" from Instant Actions.
  9. Click "+New Function".
  10. Select "Write your own".
  11. Give a name for the function and copy the code given below.
  12. Click On edit Arguments and choose 'Deal ID' and name it as 'dealId' and choose 'Deal Owner ID' and name it as 'dealownerid'
  13. Click on "Save and Associate".
  14. Save the workflow.

The Code


relatedcases = zoho.crm.getRelatedRecords("Cases", "Deals", input.dealId.toLong());
//info relatedcases;
for each ele in relatedcases
update = zoho.crm.update("Cases",ele.get("id"),{"Owner":input.dealownerid});



  • 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.
  • Change the module name in the code from "Cases" to any other module you want.

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

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

    Zoho Marketing Automation
              • Sticky Posts

              • Zoho User Group (ZUG) in-person Meetups

                Hello Zoho Community, We're pleased to announce the next leg of Zoho User Group in-person meetups. We're thankful for your overwhelming response to the meetups last quarter. Our teams had a blast meeting you all in person and finally being able to catch
              • Focus Group webinar - Revamped reports in Zoho CRM

                Any sales-based organization invests heavily in sales, which obviously translates to better revenue and overall growth. But how do we track how deals progress, or estimate how they will progress, or even how they performed? Blindly investing resources
              • Connect with Zoho users from your industry, virtually!

                A couple of years ago, we started setting up industry-wise channels for users with similar businesses to chat and discuss Zoho contextually. We started with Real Estate and E-commerce sectors, creating a chatroom and hosting regular meetups on niche areas
              • Tip #49: Associating Emails with Deals

                Hello folks,  Do you have multiple deals associated to your contacts in Zoho CRM? Are you struggling to find deal specific emails, with all the emails associated with a contact listed together? If yes, then this tip is totally for you!  You can associate emails with individual deals, rather than having them all listed under a contact. This helps you to access your deal based conversations more quickly and avoid looking through all your emails, searching for keywords and subject lines.  In Zoho CRM,
              • The role of a CRM admin and beyond | Small Business Heroes E10

                The tenth episode of Small Business Heroes, a CustomersSpeak series, features an interview with Troy Titus: a CRM administrator at Scale-Tec. Troy began his career by managing church activities and then moved on to gain real estate expertise by building

              Zoho Pagesense Resources

                Zoho SalesIQ Resources

                      Zoho TeamInbox Resources

                        Zoho DataPrep Resources

                          Zoho CRM Plus Resources

                            Zoho Books Resources

                              Zoho Subscriptions Resources

                                Zoho Desk Resources

                                  Zoho Projects Resources

                                    Zoho Sprints Resources

                                      Qntrl Resources

                                        Zoho Creator Resources

                                          Zoho WorkDrive Resources

                                              Zoho Campaigns Resources

                                                Zoho CRM Resources

                                                        Design. Discuss. Deliver.

                                                        Create visually engaging stories with Zoho Show.

                                                        Get Started Now