Deluge code to update related record

Deluge code to update related record

Hi there,
I got this code to update a "Deals" record with "accounts record" when it is edited/created
  1. accDetails = zoho.crm.getRecordById("Accounts",input.accId.toLong());
  2. PotentialDetails = zoho.crm.getRelatedRecords("Deals", "Accounts",input.accId.toLong());

  3. // info PotentialDetails;
  4. PotentialList = list();
  5. for each potential in PotentialDetails {
  6. // get the potential record
  7. PotentialId = zoho.crm.getRecordById("Deals", potential.get("id"));
  8. PotentialList.add(PotentialId.get("id").toLong());
  9. // PotentialList.toLong();
  10. }
  11. info "Potential ID:" + PotentialList;
  12. segment = accDetails.get("Segment1");
  13. info segment;
  14. updatePotentials = zoho.crm.updateRelatedRecord("Potentials", PotentialList.toString(), "Accounts", accId, {"Segment1": "Digital"});
  15. info updatePotentials;
But when I run it it throws and error saying the data is invalid.

So I did this test, 
  1. updatePotentials = zoho.crm.updateRelatedRecord("Deals",773870000022817004,"Accounts",773870000022790023);
  2. info updatePotentials

It still throw an invalid Data.

Got no idea what did i do wrong.
Can someone please help?

Thank you