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 activitiesconst contact_id = '{your_contact_id}'; // Replace with the actual contact IDhubspotClient.crm.contacts.associationsApi.getAll(contact_id, object_typeid).then(function(results) {const associatedActivities = results.body.results;// Filter meeting activitiesconst meetingActivities = associatedActivities.filter(activity => activity.properties && activity.properties['Meeting end time']);// Sort by meeting end time in descending ordermeetingActivities.sort((a, b) => {return new Date(b.properties['Meeting end time']) - new Date(a.properties['Meeting end time']);});// Get the most recent meeting activityconst mostRecentMeetingActivity = meetingActivities[0];const meetingEndTime = mostRecentMeetingActivity.properties['Meeting end time'];console.log('Most recent meeting end time:', meetingEndTime);}).catch(function(error) {console.error('Error fetching associated activities:', error);});