Auto-update deals with account data

Automatically update the industry field data in all deal records when it gets updated in their account record.

It's important for your salespeople to update any changes to the account information in their corresponding deal records. For example, the "Industry" field in the account record categorizes the industry in which the account operates. When this data is also present in the deal created for the account, it enables your salespeople to determine the specific needs and challenges within that industry, and tailor their interactions to close the deal. However, updating the industry information of an account in all of its deal records can quickly become overwhelming and take up a lot of time. Luckily, you can simplify this process.

All that's needed is to set up a workflow rule that triggers whenever the account's industry field is modified and then connect it to a custom function that automatically updates the corresponding field in the deal records. For further details, refer to the sections below. Read on 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 Single Line field in the Deals module. This field will hold the industry information updated from its account record. Learn more
  • Create a workflow rule for the Accounts module that triggers every time its "Industry" field is updated. Learn more
  • Write a custom Deluge function and link it with the workflow rule to update the industry information in the deal's single line field. 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 to add a custom single line field to the Deals module.

  1. Navigate to Setup > Customization > Modules and Fields.
  2. Click the Deals module to open the layout editor.
  3. Drag and drop the Single Line field from the New Fields tray to the layout.
  4. Name the single-line field (e.g., "Account Industry") and define its properties as required.
  5. Once you have finished, click Save and Close.
Add Custom Fields

Create a workflow rule

Next, you need to write and connect a custom function with a workflow rule.

  1. Navigate to Setup > Workflow Rules > +Create Rule.
  2. Select Accounts from the module dropdown list.
  3. Provide a name for the rule. For example: "Update industry info from account".
  4. Add a description (optional), then click Next.
  5. In the Execute this workflow rule based on section, do the following:
    1. Choose Record Action, then select Edit from the dropdown.
    2. Check the box for Repeat this workflow whenever a Account is edited.
    3. Choose Specific field(s) gets modified from the dropdown, then enter the condition "When <Industry> is modified to <any value>".
    4. Click Next.
  6. In the Which accounts would you like to apply the rule to? section, select All Accounts, then click Next.
  7. Under Instant Actions, select Function and Write your own.
  8. Provide a name for the function, as well as a description, if necessary.
  9. In the Deluge Script Editor, do the following:
    1. Copy and paste the code provided below.
    2. Click Edit Arguments.
    3. Choose Accounts - Account Id, name it acctId, and click Save.
    4. Click Save & Execute Script.
  10. Click Save on the workflow rule page.

The code

Code Copied
// Get all account details from the passed account ID
varCustDetails = zoho.crm.getRecordById("Accounts",acctId);
// Get the field to update
varFieldValue = varCustDetails.get("Industry");
//Get the deal records that match the account ID
varDealDetails = zoho.crm.getRelatedRecords("Deals","Accounts",acctId);
if(varDealDetails.size() > 0)
{
	//Create a list containing deal record ID and industry value mapped with destination API name
	updlist = List();
	for each  varDealRec in varDealDetails
	{
		mp = Map();
		mp.put("id",varDealRec.get("id"));
		mp.put("Account_Industry",varFieldValue);
		updlist.add(mp);
	}
	//Bulk update related deals 
	if(updlist.size() > 100)
	{
		update = zoho.crm.bulkUpdate("Deals",updlist.sublist(0,99));
		info "update : " + update;
		update1 = zoho.crm.bulkUpdate("Deals",updlist.sublist(100));
		info "update 1 : " + update1;
	}
	else
	{
		update = zoho.crm.bulkUpdate("Deals",updlist);
		info "update : " + update;
	}
}

Notes

  • Use the accurate API name of the custom single-line field in the code snippet (e.g., "Account Industry"). Learn more
  • The code above is an example of how to automatically update an account's field information in all related deals when it gets updated in the 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

  1. Click the Accounts tab.
  2. Open the account record whose industry information must be updated in their deals.
  3. Update the Industry field with a value and click Save.
    The workflow rule will be triggered.
  4. Check whether the Account Industry field was updated with the selected value in the associated deals.

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

  • ModuleDeals
  • Trigger PointWorkflow Rule
  • EditionEnterprise and above
  • ComplexityMedium
  • Implementation Time30 minutes

Features used in the solution

Custom FieldWorkflow RuleDeluge ScriptSandbox
Story Image

Looking for a custom solution?

Contact us, we will help enhance your productivity at lightning speed.

SUBMIT REQUEST

Developers: Share your solution with our community!