Get ContactID when a Contact is updated
I'm using this code from a previous question to update a field in a Contact whenever a Contact receives an email:
- //access the emails field from the Contact
- emailInfo = zoho.crm.getRelatedRecords("Emails", "Contacts", --yourcontactID--);
- //create a list of every email from that Contact
- emailList = emailInfo.get("email_related_list");
- //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 i in emailList
- {
- if(i.get("Created Time") > mostRecentDate)
- {
- mostRecentDate = i.get("Created Time");
- }
- }
- // Update the Last Contact Date with that date
- mapUp = Map();
- mapUp.put("Latest_Outreach",mostRecentDate);
- response = zoho.crm.updateRecord("Contacts", --yourcontactID--);
- }
- return;
Where it says "--yourcontactID--", I need to get the specific Contact's ID as a variable into that space. So I need a function that, when an action happens -- in this case, when a Contact gets an new email attached to it-- that Contact's ID is captured and that ID is then used in the code above.
Here's how I'd like it to work:
1. An email is attached to a Contact using the BCC dropbox
2. A workflow action is triggered and runs the code above
3. At the start of that code, the ContactID is captured and set to a variable
4. The rest of the above code executes