Update deal with sum of all quotes

Automatically update the deal amount to reflect the sum of all related quotes, eliminating the need for manual calculations and adjustments in your CRM.

When salespeople create a deal, they typically enter an estimated amount representing its potential value. After they add a formal quote for the deal detailing the pricing for a product or service, this amount is updated to reflect the aggregated value of the quote. However, updating the deal amount can become tedious when multiple quotes are involved. What if the deal amount could be automatically calculated and updated with the sum of all related quotes? This is where our low-code tools can come in handy.

You can create a custom function that automatically sums up the value of all related quotes and updates it in the deal record. It is necessary to trigger this function when creating a quote record using a workflow rule to include the quote's value in the deal amount computation. Read on to learn more.

Permissions and availability

  • Users with the Manage Automation permission can create and update workflow rules.
  • Users with the Manage Extensibility permission can write custom functions.
  • Users with the Manage Sandbox permission can manage the sandbox.

Requirements

  • Create a workflow rule for the Quotes module that triggers every time a new quote is created or edited. Learn more
  • Write a custom Deluge function that computes and updates the sum of all quotes in its deal and link it with the workflow rule. Learn more
  • Test the workflow rule in a sandbox before deploying it in your production environment. Learn more

Create a workflow rule

Follow these steps to create a workflow rule that updates the deal amount upon creating or editing their quotes:

  1. Navigate to Setup > Workflow Rules and click +Create Rule.
  2. Select Quotes from the module dropdown list.
  3. Provide a name for the rule. For example: "Update deal amount from quotes".
  4. Add a description, if required, then click Next.
  5. In the Execute this workflow rule based on section, do the following:
    1. Choose Record Action, and then select Create or Edit from the dropdown.
    2. Check the box for Repeat this workflow whenever a Quote is edited.
    3. Click Next.
  6. In the Which quotes would you like to apply the rule to? section, select All Quotes, 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. On the Deluge Script Editor, do the following:
    1. Copy and paste the code given below.
    2. Click Edit Arguments.
    3. Enter the name as dealId, select the value as Deals - Deal Id, then click Save.
    4. Click Save & Execute script.
  10. Click Save on the workflow rule page.
Create Workflow Rule

The code

Code Copied
rsp = zoho.crm.getRelatedRecords("Quotes","Deals",dealId);
mp = Map();
total = 0;
for each  ele in rsp
{
	ab = ifnull(ele.get("Grand_Total"),0);
	total = total + ab;
	info total;
	mp.put("Amount",total);
}
up = zoho.crm.updateRecord("Deals",dealId,mp);
info up;

Notes

  • Make sure to use the accurate API names for their corresponding fields in the code snippet (e.g., Grand Total). Learn more
  • The code above is an example of how to automatically update the deal amount to reflect the sum of all its related quotes during their creation or modification. You can use this code for any other module, such as Sales Orders or Invoices, 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. Navigate to the Deals module.
  2. Open a deals record for which you want to create a quote.
  3. On the Deal Details page, click the + icon alongside Quotes in the Related List section.
  4. On the Create Quote page, enter the quote details, including items as required, and click Save.
    The workflow rule will be triggered.
  5. Check whether the amount field of the deal reflects the total quoted amount.
  6. Create additional quotes for the deal to confirm all amounts add up to the deal's amount.

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
  • ComplexityLow
  • Implementation Time15 minutes

Features used in the solution

Workflow 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!