Skip to content

Instantly share code, notes, and snippets.

@jeznag
Created May 31, 2015 06:58
Show Gist options
  • Save jeznag/7e12bf5c68a36ad44fbd to your computer and use it in GitHub Desktop.
Save jeznag/7e12bf5c68a36ad44fbd to your computer and use it in GitHub Desktop.
Update amount for Zoho CRM potential based on related products
potential_obj = zoho.crm.getRecordById("Potentials", potential_id);
related_products = zoho.crm.getRelatedRecords("Products", "Potentials", potential_id.toString(), 1,200);
total_amount = 0.0;
for each product in related_products {
total_amount = total_amount + product.get("Unit Price").toDecimal();
}
potential_obj.put("Amount", total_amount);
potential_obj.put("Populate amount based on products associated", false);
update_resp = zoho.crm.updateRecord("Potentials", potential_id.toString(), potential_obj);
info("Response: " + update_resp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment