Using Custom Code to get activity dates in contact workflow
I'm trying to create a workflow that reminds sales reps to mark meetings completed after the fact, but using last activity date in combination with some custom dynamic date fields (Today's date, Yesterday's date) doesn't resolve the issue as I can't specify the type of activity for the last activity date, so when a rep sends an email or any other activity is added to the contact record, the contact enrols in the workflow (based on the other enrolment criteria like meeting outcome is scheduled etc.).
I think the only way I'm going to be able to resolve the issue is to find a way of getting the "Meeting end time" property from the activity into a contact property, so that I can then use the "is after another property" function to compare the end time and today's date. My understanding is that it is possible to pull data from properties on associated objects through the custom code function, but I'm not a developer myself and playing around a little with GPT to write something hasn't got me anything that works.
Any ideas on how this can be achieved?
For reference, here's what GPT produced:
const object_typeid = '0-4'; // The objecttypeid for activities const contact_id = '{your_contact_id}'; // Replace with the actual contact ID
// Sort by meeting end time in descending order meetingActivities.sort((a, b) => { return new Date(b.properties['Meeting end time']) - new Date(a.properties['Meeting end time']); });
// Get the most recent meeting activity const mostRecentMeetingActivity = meetingActivities[0]; const meetingEndTime = mostRecentMeetingActivity.properties['Meeting end time'];
I've got the meeting outcome in my enrolment criteria but the issue is that I only want to trigger the task after the meeting end date has passed, so that I'm not creating the task reminder before the meeting has even happened. However, there's no way of using the Meeting End Date (or any of the other meeting properties) in conjunction with a contact property i.e. Meeting End Date is after Today's Date (a custom property dynamically updated on the Contact record).
Your previous suggestion, to use the Contact time based workflow would work if all our meetings were booked through the HubSpot meetings tool, but unfortunately we also use calendly which integrates with HubSpot to create a meeting but, as I understand it, doesn't trigger the "Date of last meeting booked in meetings tool" criteria.
Keen to jump on a call and chat through a solution though, really appreciate your help! How do we set that up?