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:

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Auto update info across CRM".
  3. Select the moduleto be associated as Accounts. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit arguments".
  6. Enter the name as "acctId" and select the value as "Account Id".
  7. Click Save & Execute Script.
  8. Save the changes.
 

The Code:


	accountIdStr=input.accountId.to.String();
	relatedcontacts = zoho.crm._getRelatedRecords("Contacts", ("Accounts"), accountIdStr);
	info relatedcontacts;
	for each ele in relatedcontacts
	{
	contactId = ifnull(ele.get("CONTACTID"),"");
	mp=map();
	mp.put("Contact Type", input.type );
	update = zoho.crm._updateRecord("Contacts", contactId, 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!

Return to Tips