Custom function works when using "save and test" but not when executed by a custom schedule

Custom function works when using "save and test" but not when executed by a custom schedule

I imagine this is due to my limited understanding of the Deluge scripting, but I cannot find anything about why this may be happening.
I have a custom script (pasted below) that takes in a report. The report is just any ticket for a departing employee with the departure date and name, which I populated by making a dummy ticket. I just need a simple notification to remind us to complete some IT related tasks on the day of departure. When using "save and test" in the custom function, I receive an email and everything works flawlessly. When I set up a custom schedule to run this every day (I set to every hour just for testing), it doesn't send an email, despite returning that it has succesfully emailed me.

Executing this, the script runs:

But, running the script using a custom schedule, I do not receive an email (note, it had last been scheduled to run at 11pm, hourly just for testing):


The script, which obviously has my actual email normally:

currentTime = zoho.currenttime.toLong();//get current time in UNIX time
dataObj = reportObj.get("Query Departing Employee");
HR_email_id = "my.email@address.com";

for each data in dataObj{
technician_email = "my.email@address.com";//data.get("emailid");
workorderid = data.get("Request ID");
employeeName = data.get("Employee Name");

    //get UNIX time
    effectiveDate = data.get("Effective Date").toLong(); // get UNIX time of the current date field
//data.get("Effective Date")
timeDifference = effectiveDate - currentTime;
if(timeDifference < 86879520) //if, in UNIX seconds, it is less than 24.13 hours until the effective date:
{
//Create bulleted list for the email message
        messageText = "Termination Ticket for " + employeeName +" is due in less than a day. Please ensure the following important tasks are complete: " + "<br>";
        messageText += "<ul>";
        messageText += "<li>item 1</li>";
        messageText += "<li>item 2</li>";
messageText += "<li>item 3</li>";
messageText += "<li>item 4</li>";
        // Add more bullet points as needed
        messageText += "</ul>";
sendmail
[
to:  technician_email
subject: "Termination Ticket #" + workorderid
message: messageText
]
//Message to be printed in the schedule result
returnObj = Collection();
returnObj.insert("result":"success");
returnObj.insert("message": "Update Notification Mail sent successfully");
}
}
return returnObj;



                New to ADManager Plus?

                  New to ADSelfService Plus?