A Function to update a field in all contact records under an account?

A Function to update a field in all contact records under an account?

I largely understanding the basics of writing functions with a 1 to 1 relationship, but I'm missing something with a one to many.  I'm sure i'll need to make use of for loops, i'm just struggling to pull the information correctly.



So i have 2 use cases.

1.) I want to create a button on accounts that will update all related contacts address.
2.) I want to create an automatic function that will copy over account.AccountNotes into a read only field on contacts.AccountNotes.   The idea being sometimes i pull up a contacts records and don't realize a peculiarity of an account.  I'll trigger this every time the Account.AccountNotes field is updated, and also create another function every time a contact is created to pull this info from the Account Notes.

Just to add i have a custom multiline text field called Account_Notes.

So i'm working on #2 first.  Here is what I have so far and where i'm struggling:


  1. actid=XXXXXXX;
  2. actrec = zoho.crm.getRecordById("Accounts", actid);
  3. actnotes=actrec.get("Account_Notes");
  4. relcontrecs=zoho.crm.getRelatedRecords("Contacts","Accounts",actid);

  5. info relcontrecs;

  6. relcontids=relcontrecs.getJSON("id");
  7. info relcontids;

Now my expectation is for 'info relcontids' to return a list of 2 id's for the 2 contacts associated with the record I am testing with, but it is only returning a single id.  My next step would be to use a list of ID's in a for loop to then map the account.account_notes to the contact.account_notes field.  Not sure if that would be ideal or not though.

    Access your files securely from anywhere







                            Zoho Developer Community




                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts





                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • 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


                                                                                            Zoho Show Resources

                                                                                              Zoho Writer

                                                                                              Get Started. Write Away!

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

                                                                                                Zoho CRM コンテンツ



                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方