Populate the Amount field of a Deal by calculating the number of related products and its unit price

Populate the Amount field of a Deal by calculating the number of related products and its unit price

I am trying to use this code:



RelatedPotential = zoho.crm.getRelatedRecords("Products", "Deals", potId.toLong());
//info RelatedPotential;
unitprice = 0.0 ;
for each ele in RelatedPotential
{
unit = ifnull(ele.get("Unit_Price"),"0.0").toDecimal();
unitprice = unitprice + unit ;
}
mp=map();
mp.put("Amount",unitprice);
update=zoho.crm.update("Deals", potId.toLong(), mp);
info mp;
info update;

But when i click save and execute i recive the following error message
No se ha podido ejecutar la función
  • Value given for the variable 'potId' does not match its type Line Number:1