accountID1=input.accId.toString();
resp = zoho.crm.searchRecordsByPDC("Potentials",("accountid"),accountID1);
info resp;
total1=0.0;
total2=0.0;
Status="Active";
currTime=zoho.currenttime;
curtYear=currTime.getYear();
prevYear=(curtYear - 1);
info curtYear;
info prevYear;
numPotential=0;
for each rec in resp
{
closDate=rec.get("Closing Date");
if(closDate.toString().contains(curtYear.toString()))
{
stage=rec.get("Stage").toLowerCase();
info stage;
if(stage.contains("order"))
{
total1=(total1 + (rec.get("Amount")).toDecimal());
}
}
else if(closDate.toString().contains(prevYear.toString()))
{
stage=rec.get("Stage").toLowerCase();
info stage;
if(stage.contains("order"))
{
total2=(total2 + (rec.get("Amount")).toDecimal());
}
}
numPotential=(numPotential + 1);
}
info "total1 = " + total1;
info "total2 = " + total2;
mp=map();
mp.put("YTD Turnover",total1);
mp.put("PFY Turnover",total2);
//para comprobar si el PFY Turnover es menor de 10000 o menos de 2 potentials
/*if(total2 < 10000 || numPotential < 3){
Status = "Inactive";
}
mp.put("Account Status",Status);*/
updateResp = zoho.crm.updateRecord(("Accounts"),accountID1,mp);
info mp;
info updateResp;funciĆ³