Update Last Meeting Date on Contact Record Using Schedule-Trigger Flow

Business Problem

The sales team would like to report on the last meeting date for a Contact but when we try to use the standard Last Activity field, we see there are dates in the future. In order to solve this, we need to create a new custom field and update it with the meeting date after the meeting occurs. We only want the new field on the Contact to be updated if the date/time of the event record is in the past. In order to achieve this, we need to create a couple of things in Salesforce.

  • Last Meeting Date - date/time field on the Contact object
  • Schedule-Triggered Flow - this is a new exciting feature Salesforce has added to flow. It basically replaces the need for us to custom code a batch process. We are using a schedule-triggered flow because if the user does not edit the event record after the meeting has passed, then it will not trigger a record-triggered flow or a process builder. Schedule-triggered flow allows us to schedule a specific time to run a process on a set of records. Check here for more information on Schedule-Triggered flows from Salesforce.

Please note there are several considerations to using this feature:

  • There is a 250,000 limit on schedule-triggered flows, or the number of user licenses in your org multiplied by 200, whichever is greater. One interview is created for each record retrieved by the schedule-triggered flow's query.
  • If you configure an Update Records element to use the ID and all field values from the $Record global variable, enable Filter inaccessible fields from flow requests in your org's process automation settings. Otherwise, the flow fails because the Update Records element tries to set the values for system fields and other read-only fields.
  • View your scheduled flows under Scheduled Jobs.
  • The scheduled flow will run in the same time zone of your org - this is set under Company Information.

How to Instructions

How to Build the Flow

Here is what the final flow will look like:

  1. Go to Flows | New Flow and select Schedule-Triggered Flow

2. Configure the Schedule. Remember to schedule the time based on your org's time zone, not your user's time zone.

3. Configure Choose Object and Filter Conditions. We are filtering for Event records where there is at least one attendee.

4. Drag and drop a Decision Element onto the canvas and configure. This is needed because we could not specify this criteria in the filter conditions in the previous step.

5. Drag and drop a Get Record element onto the canvas and configure. We are looking for all of the attendees on the Event record, so we are querying the Event Relation object.

Please note: In order to see the Event Relation object, you must have the setting enabled under Activity Settings: Allow Users to Relate Multiple Contacts to Tasks and Events.

6. Drag and drop the Loop element onto the canvas and configure it to loop through the Get Attendees record collection.

7. Drag and drop the Decision element onto the canvas and configure it to filter for only Contact records. If you have Leads and Contacts on the same event record, this is will help you split the process so you can update Leads and Contacts separately. We are only solving for Contacts in this example.

{!Loop_Attendees.RelationId} Starts With 003

8. Create a Record Variable to hold the values for the Contact records.

Then drag and drop the Assignment element onto the canvas and configure it to assign the Contact ID and Last Meeting Date fields in the record variable.

    {!varContactfromAttendee.Id} Equals {!Loop_Attendees.RelationId}

    {!varContactfromAttendee.Last_Meeting_Date__c} Equals {!Loop_Attendees.Event.StartDateTime}

9. Create a Record Collection Variable for the Contact object to hold the records that need to be updated.

Drag and drop the Assignment element onto the canvas and configure it to add the Contact records to the Record Collection.

10. Drag and drop the Update Records element onto the canvas and configure it to update the Contact Record Collection.

Save your changes and click Debug to make sure the flow is working properly.

Click Activate when you have completed testing.

Note

Please Note

This flow will not update all of the Contacts with their most recent event date/time, it will only update Contacts with an Event where the date/time occurred yesterday. If you would like to update historical records, first check the number of event records you have in your org. If it is under the limits for Schedule-Flow triggers specified above, you can modify this flow to run for ALL event records, just change the arrow from the Start element to go directly to the Get Attendees element (skip the Decision Element called Event Occurred Yesterday) and make sure the Get Attendees element is configured to sort Event Relation Records by date. Unfortunately, there is not a way to sort the records by Event StartDateTime, you can only use the date/time fields on the Event Relation record - SystemModstamp, CreatedDate or LastModifiedDate are the only choices. Knowing this, you may want to update the historical Contact records manually using some Excel and Data loader work.

For any questions, comments, concerns – let us know in the comment section below!
We would love to hear from you!

Share This Story, Choose Your Platform!

About the Author

Cheryl Fernandes

Cheryl is a certified Salesforce Application Architect and is the Founder and Lead Salesforce Consultant at Blu Ninjas. She has been working with Salesforce for 12 years and has helped companies in financial services, insurance and beauty industries implement solutions on the platform. Flow is her favorite Salesforce declarative tool, it is a game changer for anyone who does not know how to code.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top