It's common for businesses to collect specific information about their customers in a custom field. Let's consider a marketing agency with multiple clients and several associated contacts. The agency wants to record the preferred communication method of its client accounts in a custom field. Ideally, this information should also be visible on the contacts associated with the client account without needing individual updates for each contact. However, this is not possible in the current version of your CRM. Is there a workaround to automatically display the preferred communication method from the client account to all their associated contacts? Well, it's just a function away.
Using a combination of a custom field, deluge script, and a workflow rule, you can automatically update custom field data across all associated contacts in an account. This way, you can maintain consistency and accuracy across all records without requiring manual entry for each contact. Continue reading to learn more.
Permissions and availability
- Users with the Modules Customization permission can add custom fields.
- Users with the Manage Automation permission can create and update workflow rules.
- Users with the Manage Extensibility permission can create custom functions.
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Add a Picklist field in the Contacts module. The function will update this field with the appropriate value from its account. Learn more
- Create a workflow rule for the Accounts module that triggers upon modifying a custom field. Learn more
- Write a custom Deluge function and link it up with the workflow rule. Learn more
- Test the workflow rule in a sandbox before deploying it to your production environment. Learn more
Add a custom field
The first step is adding the custom picklist field to the Contacts module.
- Navigate to Setup > Customization > Modules and Fields.
- Click the Contacts module to open the layout editor.
- Drag and drop the Pick List field from the New Fields tray to the desired section of the layout.
- Name the picklist field (e.g. "Preferred Communication Mode"), enter the options, and define its properties as required.
- Once you have finished, click Save and Close.
Create a workflow rule
The next step is to create a workflow rule in your CRM account.
- Navigate to Setup > Workflow Rules > +Create Rule.
- Select Accounts from the module dropdown list.
- Provide a name for the rule. For example: "Update communication mode in contacts".
- Add a description (optional) and then click Next.
- In the Execute this workflow rule based on section, do the following:
- Choose Record Action, then select Edit from the dropdown.
- Check the box for Repeat this workflow whenever an Account is edited.
- Choose Specific field(s) gets modified from the drop-down, then enter the condition "When <Preferred Communication Mode> is modified to <any value>".
- Click Next.
- In the Which accounts would you like to apply the rule to? section, select All Accounts, then click Next.
- Under Instant Actions, select Function and Write your own.
- Provide a name and description, if necessary, for the function.
- On the Deluge Script Editor, do the following:
- Copy and paste the code given below.
- Choose Accounts - Account Id and name it acctId.
- Click the + icon to add more arguments.
- Choose Accounts - Preferred Communication Mode, name it mode, then click Save.
- Click Save & Execute script.
- Click Save on the workflow rule page.
The code
relatedcontacts = zoho.crm.getRelatedRecords("Contacts", ("Accounts"), acctId.toLong());
//info relatedcontacts;
if( relatedcontacts.size()>0)
{
for each ele in relatedcontacts
{
mp = map();
mp.put("Preferred_Communication_Mode",mode);
update = zoho.crm.updateRecord("Contacts", ele.get("id"), mp);
info mp;
info update;
}
}
Notes
- Make sure to use the accurate API name of the custom picklist field (e.g., Preferred Communication Mode) in the code snippet. Learn more
- The code above is an example of how to automatically update custom field information in related contacts when it gets updated in their account record. You can use this code to update fields in any other module, such as Leads or custom, by modifying the module name and parameters.
Tip
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Navigate to the Accounts module and select the account whose communication mode you wish to update.
- On the Account Details page, update the Preferred Communication Mode to the appropriate value (e.g., Email).
The workflow rule will be triggered. - Check whether all contacts associated with the account reflect the new mode of communication in their corresponding field.
Did you find this useful? Try it out and let us know how it works. Share this with your team if they'd benefit from it! If you have questions, please don't hesitate to contact us.
More info
- ModuleAccounts
- Trigger PointWorkflow Rule
- EditionEnterprise and above
- ComplexityMedium
- Implementation Time30 minutes

Looking for a custom solution?
Contact us, we will help enhance your productivity at lightning speed.
SUBMIT REQUEST