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:
- actid=XXXXXXX;
- actrec = zoho.crm.getRecordById("Accounts", actid);
- actnotes=actrec.get("Account_Notes");
- relcontrecs=zoho.crm.getRelatedRecords("Contacts","Accounts",actid);
- info relcontrecs;
- relcontids=relcontrecs.getJSON("id");
- 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.