I have a very simple custom function to validate whether a lead is over 18 years old.
It reads correctly, saves correctly, and gives the correct output in the log info. However it does NOT update the record. Test data should return "false" and uncheck the box. It returns as "false" but nothing happens.
The function takes 2 arguments: DOB as date of birth, and CurrentRec as lead ID
Here's the code:
---------------------
leadrec = zoho.crm.getRecordById("Leads",CurrentRec);
DOBDecimal = DOB.getYear() + DOB.getDayOfYear() / 365;
todayDecimal = zoho.currentdate.getYear() + zoho.currentdate.getDayOfYear() / 365;
age = (todayDecimal - DOBDecimal).floor();
if(age >= 18)
{
leadrec.update("Over_18" , "true");
info "true";
}
else
{
leadrec.update("Over_18" , "false");
info "false";
}
I have tried quotes around "false" and no quotes, tried using an integration task (zoho.crm...) . Nothing.
This needs to fire on any creation or edit of a lead record where the DOB field is not null.
Any help please? It has to be something dumb I'm missing.