Auto Populating Amount in Deal from Products Selected
I am trying to use below code found in a Zoho blog to auto populate an amount field in a Deal
- products = zoho.crm.getRelatedRecords("Products", "Deals", potId.toLong());
- unitprice = 0.0;
- for each product in products
- {
- unit = ifnull(product.get("Unit_Price"),"0.0").toDecimal();
- unitprice = unitprice + unit;
- }
- mp = Map();
- mp.put("Amount",unitprice);
- update = zoho.crm.updateRecord("Deals",potId.toLong(),mp);
- info mp;
- info update;
The function executes but doesn't find a product list, console output below
- {"Amount":0.0}
- {"Modified_Time":"2023-05-26T00:20:17+01:00","Modified_By":{"name":"Denise Flitcroft","id":"584257000000376001"},"Created_Time":"2023-05-25T23:59:17+01:00","id":"584257000000548959","Created_By":{"name":"Denise Flitcroft","id":"584257000000376001"}}
- Function executed successfully
Any idea where I'm going wrong?