Function only works when record is updated manually

Function only works when record is updated manually

I have been creating a function to update a datetime field on the Supplier (Vendor) when a field is updated on the Contact. If I manually change the field all works fine, but if the record is updated by a workflow or function nothing happens.

This is the function:

contact = zoho.crm.getRecordById("Contacts",contact_id);
email_activity = contact.get("Last_Email_Activity").toDateTime("yyyy-MM-dd'T'HH:mm:ss+00:00");
info email_activity;

supplier_id = contact.get("Supplier").get("id");
supplier = zoho.crm.getRecordById("Vendors",supplier_id);
last_activity = supplier.get("Last_Activity").toDateTime("yyyy-MM-dd'T'HH:mm:ss+00:00");
info last_activity;

if(email_activity > last_activity)
{
date_time_update = contact.get("Last_Email_Activity");
info date_time_update;
mp = Map();
mp.put("Last_Activity",date_time_update);
supplierUpdate = zoho.crm.updateRecord("Vendors",supplier_id,mp);
}