Totalling from Related Records

[Zoho CRM] Totalling from Related Records

This function can be used to total a number from a related list. For example, you would like to calculate the revenue from the company based on the deals' amount.

Notes: acctId = Accounts ID

  1. RelatedRecords = zoho.crm.getRelatedRecords("Deals","Accounts",acctId.toLong());
  2. //info RelatedRecords;
  3. total = 0.0;
  4. for each  Deals in RelatedRecords
  5. {
  6. total = total + ifnull(Deals.get("Amount"),"0.0").toDecimal();
  7. }
  8. mp = Map();
  9. mp.put("Annual_Revenue",total);
  10. update = zoho.crm.updateRecord("Accounts",acctId.toLong(),mp);
  11. info update;
have any questions? Contact us here at Aplikasi!