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});
}

-----------------------------------------------------------------------------------------------------------------------

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.
  • 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 Desk Resources

                            • Desk Community Learning Series


                            • Digest


                            • Functions


                            • Meetups


                            • Kbase


                            • Resources


                            • Glossary


                            • Desk Marketplace


                            • MVP Corner


                            • Word of the Day



                                Zoho Marketing Automation
                                        • Sticky Posts

                                        • Tip #35 - On using Kanban View in Zoho CRM

                                          Hi folks,  It's that time of the week again, and I am back with a quick tip about using Kanban View in Zoho CRM. If you think you missed any of our previous weeks' tips, you can read them here.  Tip #35 - On using Kanban View in Zoho CRM You deal with so many records in CRM every single day! When you click open each module in Zoho CRM, you have hundreds of records, each in various stages of your sales pipeline. Wouldn't it be cool if you had them all sorted automatically without having to filter
                                        • ZUG (Zoho User Group) In-person Meetups - Learn, share and discuss all things Zoho

                                          Hi, Hope you all are well. We're excited to announce our second leg of in-person Zoho User Group (ZUG) meetups in your region. A quick update - Our first leg of meetups in 2024 progressed and reached completion smoothly, where Zoho experts had the opportunity
                                        • ZUG (Zoho User Group) In-person Meetups - Learn, share and discuss all things Zoho

                                          A big warm hello to the Zoho Community, and Happy new year to all of you! We're thrilled to let you know that our ZUG Meetups for 2024 have almost begun, and we can't wait for you to be a part of them. We have some interesting topics in store for this
                                        • Cloning Email Templates across modules in Zoho CRM.

                                          The option of cloning email templates across modules has been a long standing feature request from the Community. Thank you all for being so patient with us. We are happy to inform you all that this enhancement has been rolled out. Just in case you haven't noticed it already, cloning email templates is possible now! Cloning is useful because it cuts down the hassle of having to create the same email templates again for different modules. Here are the steps: Navigate to Settings---> Customization--->Templates
                                        • CRM Hack #2: Automate sending of birthday greetings to your customers.

                                            Hello everyone! What sets you apart as a sales person is your ability to add that personal touch to your business relationship with your customers. Sending a gift on a special day, or leaving a note wishing them on their birthdays, are small, yet significant actions that show your customers that you care. And these are actions done without any expectations :) You must be engaging with a lot of customers and it is highly unlikely that they all are your friends on Facebook or some social channel,


                                        Manage your brands on social media



                                                Zoho TeamInbox Resources

                                                  Zoho DataPrep Resources



                                                    Zoho CRM Plus Resources

                                                      Zoho Books Resources


                                                        Zoho Subscriptions Resources

                                                          Zoho Projects Resources


                                                            Zoho Sprints Resources


                                                              Qntrl Resources


                                                                Zoho Creator Resources


                                                                  Zoho WorkDrive Resources



                                                                    Zoho Campaigns 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




                                                                            Design. Discuss. Deliver.

                                                                            Create visually engaging stories with Zoho Show.

                                                                            Get Started Now