Help in function code

Help in function code

Hi,
could someone look at the code below and tell me what 's wrong with it?
After a deal creation or edition the code should find the related Account, than all open Deals for that Account and copy the field Total_Open_Deals from the Account record to all Deals at Concurrent_deals.

Total_Open_Deals is a Rollup summary field type.

  1. cnRecord = zoho.crm.getRecordById("Accounts",input.accID);
  2. relatedDeals = zoho.crm.getRelatedRecords("Deals","Accounts",input.accID);
  3. for each  relatedDeal in relatedDeals
  4. {
  5. stage = relatedDeal.get("Stage");
  6. if(!stage.contains("Closed"))
  7. {
  8.         updateMap = Map();
  9. updateMap.put("Concurrent_deals",cnRecord.getJSON("Total_Open_Deals"));
  10. updatedConcDeal = zoho.crm.updateRecord("Deals",relatedDeal.get("id"),updateMap);
  11. }
  12. }
Thanks.