Update all member accounts simultaneously when the parent account is updated

Business scenario:

It isn't strange to have multiple branches in a business. Or having contacts with multiple branches of the same company. Either way, it would be better to have multiple member accounts for easier identification rather than have all contacts under a single account and lose track of who to contact in which branch. Zoho CRM facilitates the creation of multiple branch accounts (named 'member accounts') which are linked to a parent account.

As useful as this is, if there are any changes made to a parent account. Say, for instance, change of websites, social media pages, activities, deals, etc, then there lies the task of updating each member account manually once again. The process is repetitive. To spare you the effort of manual work, this custom function automates the process by updating the member accounts simultaneously when the parent account is updated.

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: "Update Deal Progression".
  3. Select the module to be associated as Deals. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit Arguments".
  6. Enter the name as "parentaccId" and select the value as "Account Id".
  7. Enter the name as "parentownerId" and select the value as "Account Owner ID".
  8. Click Save & Execute Script.
  9. Save the changes.
  10. Use the custom function in conjunction with a Workflow rule to enable auto-update of member accounts.
 

The Code:


relatedaccount = zoho.crm.getRelatedRecords("Child_Accounts", "Accounts", parentacctId.toLong()); 
//info relatedaccount.size(); 
//info relatedaccount;
for each ele in relatedaccount 
{ 
mp=map(); 
mp.put("Owner",input.parentownerId); 
update = zoho.crm.update("Accounts", ele.get("id").toLong(), mp); 
info mp; 
info update; 
}

 

Note:

  • The above code works only for API V2.0 and not the previous version.
 

Found this useful? Try it out and let us 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