We would like to have all leads outside of business hours assigned to person 1. The rest should be assigned to person 2.
I have the following function, but it doesn't seem to work correctly. Leads are all being assigned to 4972398000081238001.
Can anyone see where I've gone wrong? I am stumped.
- leadDetails = zoho.crm.getRecordById("Leads",input.leadId);
createdtime = ifnull(leadDetails.get("Created_Time"),"");
info createdtime;
if(createdtime != "")
{
createddatetime = createdtime.toTime();
// convert to DateTime object
createdhour = createddatetime.getHour();
createdday = createddatetime.getDayOfWeek();
// 1 = Sunday, 2 = Monday, ..., 7 = Saturday
info createdhour;
info createdday;
if(createdday >= 2 && createdday <= 6)
{
// Monday to Friday
if(createdhour >= 8 && createdhour < 19.5)
{
// 8:30 am to 7:30 pm
owner = 4972398000074706001;
}
else
{
// 7:30 pm to 8:30 am
owner = 4972398000081238001;
}
}
else
{
// Saturday and Sunday
owner = 4972398000081238001;
}
mp = Map();
mp.put("Owner",owner);
update = zoho.crm.updateRecord("Leads",input.leadId.toLong(),mp);
info mp;
info update;
}
else
{
info "Created time is empty.";
}