Update deal information in accounts

Automatically update custom field data from a deal record to its related account to ensure all team members can access up-to-date information.

When closing deals, important customer details, such as billing email, last contact date, next contact date, and other relevant custom information, are entered into a deal record. Equally important is updating this information in the associated account to ensure that all team members have access to the most up-to-date account information. Implementing a one-click automation to transfer this information when a deal is created or edited would be very beneficial. This is where a custom function can be helpful, particularly when combined with a workflow rule.

Using a custom function, you can transfer necessary data from deals into their respective fields in the account record. You can then link this function to a workflow rule that triggers when a deal record is created or edited.

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 the required custom fields in the Deals module to the Accounts module. For example, add billing email (email type), last contact date (date type), and next contact date (date type) fields. Learn more
  • Create a workflow rule for the Deals module that triggers every time a deal is created or edited. 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 custom fields

Assuming the custom fields are already part of the deals module, the first step is to add them to the accounts module.

  1. Navigate to Setup > Customization > Modules and Fields.
  2. Click the Accounts module to open the layout editor, and do the following:
    1. Drag and drop the required field types to the desired section of the layout.
    2. Name the custom fields (e.g. "Billing Email, Last Contact Date and Next Contact Date") and define their properties as required.
  3. Once you have finished, click Save and Close.
Add Custom Fields

Create a workflow rule

The next step is to create a workflow rule in your CRM account.

  1. Navigate to Setup > Workflow Rules > +Create Rule.
  2. Select Deals from the module dropdown list.
  3. Provide a name for the rule. For example: "Update deal info in accounts". 
  4. Add a description (optional), then click Next.
  5. In the Execute this workflow rule based on section, do the following, choose Record Action, select Create or Edit from the dropdown, and click Next.
  6. In the Which deals would you like to apply the rule to? section, select All Deals, then click Next.
  7. Under Instant Actions, select Function and Write your own.
  8. Provide a name and description, if necessary, for the function.
  9. On the Deluge Script Editor, do the following:
    1. Copy and paste the code given below.
    2. Click Edit Arguments.
    3. Choose Deals - Deal Id, then name it dealId.
    4. Click the + icon to add more arguments.
    5. Choose Accounts - Account Id, name it accId.
    6. Click Save, then click Save & Execute Script.
  10. Click Save on the workflow rule page.

The code

Code Copied
resp = zoho.crm.getRecordById("Deals", dealId);
mp = map();
mp.put("Billing_Email", ifnull(resp.get("Billing_Email"),""));
mp.put("Last_Contact_Date", ifnull(resp.get("Last_Contact_Date"),""));
mp.put("Next_Contact_Date", ifnull(resp.get("Next_Contact_Date"),""));
info "Map : "+mp;
upd = zoho.crm.updateRecord("Accounts", accId, mp);
info upd;

Notes

  • Make sure to use the accurate API names for their corresponding fields (e.g., "Billing Email") in the code snippet. Learn more
  • You can include as many fields as needed in the code snippet to transfer their information from deals to accounts.
  • The code above is an example to update custom field data from a deal to its related account record. You can use this code for any other module, such as leads or custom, by modifying the module name and parameters.

Test the solution

  1. Navigate to Deals > + Create Deal.
  2. On the Deal Details page, enter the Account Name associated with the deal and input data for other custom fields included in the code snippet, then click Save.
    The workflow rule will be triggered.
  3. Check whether the account associated with the deal reflects the details entered in their respective deal fields.
  4. Try editing an existing deal associated with an account to check whether their field information was updated in the account.

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!