Populate the Amount field of a Deal by calculating the number of related products and its unit price.
I’m sure you’d agree that the Deal Dashboards is one of the most sought after widgets in Zoho CRM. One of my favorite ones is “Pipeline by Stage” widget that gives a clear indication of your sales pipeline across various deal stages. It gives a fair idea of your revenue pipeline, helps you understand whether you’d be able to meet your sales targets, and take necessary corrective actions if required.
Now here's the tricky part. To make better use of these dashboards, your users have to update all the deal values diligently. Unless the Amount field in the deal is filled accurately, the pipeline dashboard is of little use. Filling the Amount field manually creates a room for error. Moreover, the field could be left blank initially and be updated only at later stages of the deal. Automation removes the scope for such errors. This week’s custom function helps address this problem with ease. The Amount field is dependent on the product details included in the deal. You don't have to calculate the amount that is to be transacted in the deal. This custom function populates the "Amount" field with the information from the "Products" Related List.
Amount field = ((Order quantity of P1 x Unit price of P1)+(Order quantity of P2 x Unit price of P2)+....).
P1, P2, .... denote the individual products in the deal.
Getting started with the function:
- Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
- Provide a name for the function. For example: "Auto Update Tasks from related lists".
- Select the moduleto be associated as Tasks. Add a description(optional).
- Copy the code given below.
- Click "Edit Arguments".
- Enter the name as "dealId" and select the value as "Deal Id".
- Click Save & Execute Script.
- Save the changes.
For v2 Editor - DRE:
RelatedPotential = zoho.crm.getRelatedRecords("Products", "Deals", potId.toLong());
unitprice = 0.0 ;
for each ele in RelatedPotential
unit = ifnull(ele.get("Unit_Price"),"0.0").toDecimal();
unitprice = unitprice + unit ;
update=zoho.crm.update("Deals", potId.toLong(), mp);
- This function code works only when you have the latest version of Zoho CRM's APIs.
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!