Want update a date field based on most recent email date
I want to automatically update a date field in a Contact when a new email is attached to that Contact. This is a field created for the Contact layout called "Last Outgoing Contact". I created a function to do this, but it doesn't appear to work.
- //access the emails field from the Contact
- emailInfo = zoho.crm.getRelatedRecords("Contacts","ID","Emails","Emails");
- //create a list of every email from that Contact
- emailList = emailInfo.get("Emails");
- //count the number of emails in that list
- count = emailList.size();
- //if the number of the emails in the list is greater than 0, get the most recent email's Created Time date
- if(count > 0)
- {
- mostRecentDate = emailList.get(0).get("Created Time");
- for each index i in emailList
- {
- if(emailList.get(i).get("Created Time") > mostRecentDate)
- {
- mostRecentDate = emailList.get(i).get("Created Time");
- }
- }
- // Update the Last Contact Date with that date
- put("Latest Outgoing Contact",mostRecentDate);
- }
- return;