Auto update Account information across CRM
Take a case of leads captured through web-forms. Most leads don't fill out the entire form. Once the lead is prospected, you go on to create relevant records in contact and accounts module. Now that you qualified the leads, you don't want to miss out on an opportunity to collect more details, do you? When you update these details in the accounts module, you'd want these to be automatically updated in the contacts module as well. This week's custom function helps in doing just that.
And it isn't just the Contacts module that gets updated. The related fields in any selected module, including custom modules, is auto-updated using this custom function. To apply this custom function to other modules, simply update the module names and ID in the code.
Getting started with the function:
- Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
- Provide a name for the function. For example: "Auto update info across CRM".
- Select the module to be associated as Accounts. Add a description(optional).
- Copy the code given below.
- Click "Edit arguments".
- Enter the name as "acctId" and select the value as "Account Id".
- Click Save & Execute Script.
- Save the changes.
The Code:
relatedcontacts = zoho.crm.getRelatedRecords("Contacts", ("Accounts"), accountId.toLong());
//info relatedcontacts;
for each ele in relatedcontacts
{
mp=map();
mp.put("Contact_Type", input.type );
update = zoho.crm.update("Contacts", ele.get("id"), mp);
info mp;
info update;
}
Note:
- The code is zoho.crm._getRecordById for Version 1.0 of APIs.
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!