Record the Last Event With A Contact (2023)

Record the Last Event With A Contact (1)

Record the Last Event With A Contact (2)

Your company has a business model where multiple sales people representing different channels or product focuses, or an internal/external sales team, may interact with the same individual. There is a business need to track calls to the contact or events with the contact.

These two use cases will be covered in a 2-part article series.

  1. Record the last call made to a contact
  2. Record the last event with the contact

This article will cover the use case to track the last completed event date with the contact in Salesforce. While this can be done in custom code, we are able to accomplish this with a record triggered after save flow and hidden screen flow added to the lightning record page.

Few things to note:

  • This works in Lightning Experience.
  • This solution works where the contact is the primary contact of an event or in an organization where you have not enabled the feature “Allow Users to Relate Multiple Contacts to Tasks and Events.”

Here are a few lessons learned from implementing this use case:

  • If a previously created event is deleted from the contact record, upon the next visit to the detail contact record will recalculate and remove the deleted event from being evaluated for display on the Last Event Date field.
  • Salesforce considers an event as completed (i.e. moves it into Activity History) after the event’s start date/time has past.
  • All events, regardless of all day or not, will have a Date field (API name: ActivityDate), Start Date/Time (API name: StartDateTime) and End Date/Time (API name: EndDateTime).
  • Provide descriptions, where provided, in Salesforce. This may be tedious step, I know, but your future self will thank you when you are trying to remember what you configured or assist other/future admins when troubleshooting or enhancing what was built. This includes noting the data stored in a custom field, noting where a visual flow is invoked from, the purpose of a flow variable, what a visualforce page does, etc.

Business Use Case: Addison Dogster is a system administrator at Universal Container. Sammy Sunshine is a Sales Manager who requested that we track the most recent event with the contact in Salesforce.

Solution: It would’ve been easy for Addison to throw this over the way to the developer to develop custom code. However, being the Awesome Admin that she is, Addison was able to help Sammy through declarative actions with one custom fields (Activity and Contact objects), a record triggered after save flow, screen flow and an update to the contact page layout(s) to add the Last Event Date field.

Record the Last Event With A Contact (3)

The above record triggered after save flow will look up the most recent event for the contact and update the last event date on the contact (1) when a new event is created where the whoId is not blank and (2) 0 days after the event’s start date time where the whoId is not blank.

Record the Last Event With A Contact (4)

The above screen flow will look up the most recent event for the contact and update the last event date on the contact and show blank screen as its last element. This will allow it to appear “hidden” on the lightning record page.


Quick Steps:

1. Create an Contact custom field (Customize | Contacts | Fields), create a new field that will track the most recent call task date.

Record the Last Event With A Contact (5)

1a. Set the field level security to be visible for all applicable profiles and editable to profiles that would create events.

1b. Add this field to the contact page layout where you’d want to track the last event date. Mark this field on the page layout as Read Only.

Best practice tips for custom fields:

  • Don’t forget to provide a description so you and other/future admins know what these fields are used for.
  • Set the FLS (field level security) for each profile. Only make the field visible and editable for the profiles that need it. Do not just click the “Next” button when you are on the screen.
  • Select only the page layouts that the new fields need to be added to. By default, new fields are added to all page layouts. Once the field(s) is/are added, you may need to update the page layout to move the field(s) to the desired location on the page.

2. Create the screen flow shown above. In Classic, go to Create | Workflows & Approvals | Flows. In Lightning Experience, it is found under Process Automation | Flows. Click on “New Flow.” Select Screen Flow. Click on the Create button. This flow will perform a lookup of events for the specified Contact based on the smallest positive duration from the event date and current date/time and update the Last Event Date field with the most recent event that has passed.

A. First, we will create a Get Records called “Lookup Most Recent Primary Event.” This will lookup the contact’s events where the Event Subtype = Event, Start Date/Time is greater than or equal to the current date/time and the attendee (WhoID) is the contact. Then based on the query, take the event with the most recent start date/time (descending order).

You’re probably wondering why I’m using the most recent start date/time instead of the end date/time. This is because Salesforce considers an event as completed or moved into Activity History when the event’s start date/time has passed.

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this get records flow element does.

Configure it as shown below:

  • Object: Event
  • Condition Requirements: All Conditions Are Met (AND)
    • StartDateTime Less Than or Equal {!$Flow.CurrentDateTime}
    • EventSubtype Equals Event
    • WhoId Equals {!$Record.WhoId}
  • Sort Event Records: Descending StartDateTime
  • How Many Records to Store: Only the first record
  • How to Store Record Data: Automatically store all fields

Record the Last Event With A Contact (6)

B. Next, create an Update Records flow element called “Update Contact’s Last Event Date” to update Last Call Date field with the value the ActivityDate field in the Contact record where the ID matches the WhoId field. If in Classic, we will pass the the contactId in the recordId variable in flow from the visualforce page.

(Video) 2018 ROGUE RECORD BREAKER | Cyr Dumbbell - Full Live Stream Event 2

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this update record flow element does.

Configure it as shown below:

  • How to Find Records to Update and Set Their Vales: Specify conditions to identify records, and set fields individually
  • Object: Contact
  • Condition Requirements for Records to Update: All Conditions Are Met (AND)
    • Id Equals {!$Record.WhoId}
  • Set Field Values for the Contact Records:
    • Last_Event_Date__c: {!Lookup_Most_Recent_Primary_Event.ActivityDate}

Record the Last Event With A Contact (7)

C. Create a Screen flow element called “Blank Screen.” Under Configure Frame deselect both Show Header and Show Footer.

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this screen flow element does.

Configure it like this:

Record the Last Event With A Contact (8)

D. Add the subflow Send Flow Fault Email. For instructions on how to create this, go to Step 2 of blog post: Maximize Maintainability With Process Builder and Componentized Visual Workflow.

E. Connect the flow elements and fault connectors to match the below…

Record the Last Event With A Contact (9)

Can’t seem to get the fault connector to appear? Create a temporary flow element (circled below), draw your first connector to that temporary flow element. Then, draw another connector to the send element. This connector has the word “FAULT” in it.

Once that is completed, delete the temporary flow element you created. This is the end result.

F. Name your flow and save.

(Video) Are climate targets now pointless?

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this flow is used for, where it is invoked from.

Record the Last Event With A Contact (10)

G. Click the Activate button.

3. Add the screen flow created in Step 2 to the contact lightning record page via Lightning App Builder.

Record the Last Event With A Contact (11)

4. Clone the flow created in Step 2 above. Open the flow from Step 2.

A. Click the Save As button, Select “A New Flow”, provide a new name “Update Contact Last Event Date – After Event Save“, select “Record Triggered Flow” as the Type.

Best practice tip: Don’t forget to provide a description so you and other/future admins know the purpose of this record triggered flow.

Record the Last Event With A Contact (12)

B. Click Edit in the Trigger section in Start.

Configure it to match below.

  • Trigger the Flow When: A record is created or updated
  • Run the Flow: After the record is saved

Record the Last Event With A Contact (13)

C. Click Edit in the Object section in Start.

(Video) Speedrunner Fakes World Record During A CHARITY EVENT!

Configure it to match the below…

  • Object: Event
  • Condition Requirements: All Conditions Are Met (AND)
    • WhoId Is Null False
  • When to Run the Flow for Updated Records: Only when a record is updated to meet the condition requirements

Record the Last Event With A Contact (14)

D. Click Edit in the Scheduled Paths section in Start.

Configure it to match the below…

  • Path Label: 0 Days After the Event Start Date/Time
  • Time Source: Event: Start Date Time
  • Offset Number: 0
  • Offset Options: Days After

Record the Last Event With A Contact (15)

E. Draw the connectors for the paths and normal connector as shown.

Record the Last Event With A Contact (16)

F. Click Save and Activate.

4. If the “Run Flows” permission is not enabled for the profile who will need to update the Last Event Date, you need to enable this under System Permissions.

That’s it. Congrats, you’ve implemented the solution!

Now, before you deploy the changes to Production, you need to test your configuration changes.

  1. Login as a salesperson and navigate to a contact record.
  2. Log an event that has passed.
  3. Navigate back to the detailed contact record.
  4. Verify that the Last Event Date is updated to match the event start date/time from Step 2.
  5. Repeat this for an all day event that has passed.
  6. Verify that the Last Event Date is updated to match the event start date/time from Step 2.
  7. Log an event with a future start date/time.
  8. Verify that the Last Event Date has not been updated to match the event start date/time from Step 7.
  9. Once the event’s start date/time has passed, navigate back to the contact’s detailed record. Verify that the Last Event Date field has been updated to match the event start date/time from Step 7.
  10. Repeat Steps 1-9 for each profile that has access to this field.

Deployment Notes/Tips:

  • The contact custom field, contact page layout(s)*, lightning record page, flows can be deployed to Production in a change set.

*Assuming your page layouts are in sync with production (only includes the new custom field and not others in progress), you can deploy page layouts in a change set. Otherwise, if you are not sure, I suggest manually adding the new field to the contact page layout in Production to avoid accidentally overriding production with an older version.

(Video) Record breaking Buffalo Snow - Lake Effect - November 2022

  • The field level security for the custom fields and the “Run Flows” system permission enablement will need to be manually updated post deployment. I would caution against adding the related profiles in the changeset for deployment as the results of deploying a profile are not reliable. If you have a tool like Snapshot by Metazoa, you can use the tool to deploy field permissions and profile system permissions.
  • Activate the flows after they deployed in Production as flow are deployed as inactive.


What is Lastactivitydate in Salesforce? ›

Example: If a Record has multiple Activities, the "Last Activity" date will be the Due Date of the Activity furthest in the future. If the Activity Due Dates are 1/10/2018 and 2/10/2018, the Last Activity will be 2/10/2018. Notes: A single Task may be related to more than one record.

What triggers last activity in Salesforce? ›

The last activity date for a contact or lead is based on all the activities that are related to that contact or lead via the Name field. If Shared Activities is enabled, an account's last activity date is still based on the activities that roll up to the account via the Related To field.

Can we update record using process builder? ›

Process Builder, when you create a Process for a Task or an Event, does not give you a direct way to update data on the record through the Related to (WhatID) or Name (WhoID) fields.

How do you update related records using process builder? ›

Click the 'Object' Picklist, then select the Account record that started your process and select a record related to the Account: Note: These records are radio buttons, and only one may be selected. To update child records, select the send option 'Select a record related to the Account'

What is LastReferencedDate in Salesforce? ›

LastReferencedDate is the timestamp for when the current user last viewed a record related to this record. The distinction is viewing this record versus viewing a record related to this record.

How do I create a last activity date field in Salesforce? ›

  1. Click “New”
  2. Choose “Formula”
  3. Click “Next”
  4. Enter Field label.
  5. Choose “Number”
  6. Click “Next”
  7. Enter “TODAY() - LastActivityDate” inside the formula box.
  8. Click “Next”

How do I get the last record in a list in Salesforce? ›

If you want to find the latest record just run a query ordered by created date: Custom_Object__c co = [select Id from Custom_Object__c order by CreatedDate desc limit 1]; If you want the last record that was modified use LastModifiedDate instead.

Can you track activity on Salesforce? ›

With Event Monitoring, you can track user activity and prevent data loss. Event Monitoring provides the audit log files from Salesforce. These logs contain information about nearly 50 unique, user-generated events.

How do I see recent activity in Salesforce? ›

To view your Recent Activity page, go to the Ideas tab and click your Nickname link on the right side of the page. To view the Recent Activity page of another member of the zone, click the member's name below any idea or comment that they posted.

How do you update a record without updating the strategy? ›

How can we update a record in target table without using Update strategy? A target table can be updated without using 'Update Strategy'. For this, we need to define the key in the target table in Informatica level and then we need to connect the key and the field we want to update in the mapping Target.

Can you update a record without updating its system fields? ›

Yes, you can do it by using a function autoSysFields() in your server-side scripting. Whenever you are updating a record set the autoSysFields() to false. 'autoSysFields' is used to disable the update of 'sys' fields (Updated, Created, etc.) for a particular update.

Which command is used to modify or update a record? ›

Answer: The UPDATE command is used to modify the records of a table.

What do you mean by updating records? ›

the act of changing something to bring it up to date (usually by adding something) “criminal records need regular updating” type of: change. the action of changing something.

What are the 11 actions in process builder? ›

Process builder features:
  • Create a Record​ Creates a record by manually entering values or by using the values of related records.
  • Update any related record. ...
  • Quick Actions. ...
  • Launch a Flow. ...
  • Send an Email. ...
  • Post to Chatter. ...
  • Submit for Approval. ...
  • Apex.

How do you update a record in SAP? ›

  1. Define the selection criteria. You can select update requests by the following properties. ...
  2. Choose. (Execute (F8)). ...
  3. Analyze the result. Green color in the Status field means that the update is currently running or has not yet started. ...
  4. Examine the updates in more detail, or make changes to them.

What is @track in Salesforce? ›

What is Field History Tracking? Salesforce field history tracking is a method that can be used to track changes associated with each specific field. It can be used for both standard objects as well as custom objects that are specific to your company. For a particular field, the process is straightforward.

What does && mean in Salesforce? ›

Evaluates if two values or expressions are both true. Use this operator as an alternative to the logical function AND.

What is an account date of last activity? ›

What Is a DLA (Date of Last Activity)? The date of last activity is exactly what it sounds like: it is the most recent date on which activity was reported for an account.

What is the last modified date in Salesforce? ›

'LastModifiedDate' is the date and time when a record was last modified by a User, and 'SystemModstamp' is the date and time when a record was last modified by a User or by an automated process (such as a trigger.)

How do I create a recent record in flow Salesforce? ›

To get the last opportunity created you can build and autolaunched flow with a get element that quieries the first Opportunity record sorted descending created date field (this is a system field that is already available). If you want to display the result on screen build a screen flow and do the same.

How do you display the last record in a table? ›

We can use the ORDER BY statement and LIMT clause to extract the last data. The basic idea is to sort the sort the table in descending order and then we will limit the number of rows to 1. In this way, we will get the output as the last row of the table.

How do I find the last row in a database? ›

To select the last row, we can use ORDER BY clause with desc (descending) property and Limit 1.

How can I get last record of a table in SQL? ›

In Oracle, the ROWNUM keyword is used in the WHERE clause for retrieving the last record from the table.

Can you report on activity history in Salesforce? ›

Activity reports are useful for gathering information about open activities, completed activities, multi-person events, or pending approval requests for which you're a delegated approver. Standard activity reports allow you to select the date range and status of the activities you want included.

How do I create an activity report in Salesforce? ›

Create a Report Activity
  1. Click Interactions.
  2. Click Report.
  3. Click Create.
  4. Complete the Properties section: Name - Use this name to identify the activity. ...
  5. Complete the Parameters section. ...
  6. Complete the Report Results Delivery section.
  7. Complete the Results File Format section.
  8. Complete the Process Flow section.

How do I create a history tracking report in Salesforce? ›

To enable Field History Tracking:
  1. Go to Salesforce Setup | Create | Objects.
  2. From the list of objects select the object you would like to track fields on.
  3. Go to the Custom Fields and Relationships section of the page.
  4. Click "Set History Tracking"
  5. Select the field(s) you would like to track and click "Save"

Where can I find recent activity? ›

Find & view activity
  • On your Android phone or tablet, open your device's Settings app. Google. Manage your Google Account.
  • At the top, tap Data & privacy.
  • Scroll to "History settings."
  • Tap My Activity.

What is recent activity feed? ›

The recent activity feed displays on a tab within the profile card on some profile types. This feed lists recent updates to the profile (or related to the profile). Specific examples of tracked activities for each profile are provided further down in this entry.

How do I view event logs in Salesforce? ›

View Events in Salesforce Event Log File Browser
  1. Log in to your org.
  2. Click Production Login.
  3. Set the start Date.
  4. Select an event type for your search, or leave event type set to All.
  5. Click Apply.

Why is it important to keep an updated record? ›

Record Keeping Reduces the Risk of Fraudulent Transactions

A business must also record expense transactions in a timely manner to ensure that you only receive payment for an invoice one time. This will help to reduce the potential risk of fraudulent transactions.

Is it possible to UPDATE a single record without WHERE clause? ›

We can modify one or multiple records (rows) in a table using UPDATE statement. If you do not use WHERE clause in UPDATE statement, all the records in the table will be updated.

How do you write a record UPDATE query? ›

UPDATE table_name SET column1 = value1, column2 = value2,... WHERE condition; table_name: name of the table column1: name of first , second, third column.... value1: new value for first, second, third column.... condition: condition to select the rows for which the values of columns needs to be updated.

How do I manually update a field? ›

Update all fields in a document

Press Ctrl + A. Press F9. If your document has tables with fields or formulas, you might need to select each table separately and press F9.

Can I update same record in after trigger? ›

Record values can be updated or validated using this type of trigger before the values are saved to the database. After Triggers: After Triggers are used if the information set by the Salesforce system needs to be used or changed in other records that need to be made.

Can you update a record without updating its system fields like Sys_updated_by Sys_updated_on in ServiceNow? ›

44) Can you update a record without updating its system fields(like sys_updated_by, sys_updated_on)? Yes, you can do it by using a function autoSysFields() in your server side scripting.

Which command is used to record? ›

Explanation: The "script" command is used to record a user login session in a file.

Which command is used to make changes in a record? ›

Update command is a data manipulation command which is used to modify the data in the records of a table.

Which command is used to add the record? ›

For such situation the insert command is used. It means the insert command is used to add a new record in the middle of the database where we want. It will insert the record before the current record or after record.

What is record of event? ›

Event recording is a process for documenting the number of times a behavior occurs. An observer using event recording makes a tally mark or documents in some way each time a student engages in a target behavior. The observer also records the time period in which the behavior is being observed.

What record keeping means? ›

If you keep a record of something, you keep a written account or photographs of it so that it can be referred to later.

What is the meaning of to set a record? ›

: to achieve something no other person or thing has achieved. She set a record for the most sales in the history of the company.

What are the 4 basic components of a process? ›

These four critical items are: (1) Process Definition, (2) Process and Activity Roles, (3) Available Tools and (4) Training.

Is process builder going away? ›

Salesforce is Retiring Process Builder & Workflow Rules - Here's What You Should Do. At the end of 2022, Salesforce will be retiring Workflow Rules and Process Builder automation. While your current Workflow Rules and Process Builders will continue to run, you will not be able to create new automation using these tools ...

How do you create a record change? ›

  1. Open the Manage Change Records app from the SAP Fiori launchpad.
  2. Select Create Change Record and choose a record type from the dropdown.
  3. If the change record ID has not been generated automatically by the system, enter an ID according to the defined namespace. ...
  4. Enter a description up to 40 characters.

Should be used to update the existing record? ›

The SQL UPDATE query is used to modify the existing records in a table.

What is update statement? ›

In SQL, the UPDATE statement is used to modify or update existing records in a table. You can use it to update everything all at once, or you can specify a subset of records to modify using the WHERE clause. The UPDATE statement is considered a SQL data manipulation command.

How do I find the last modified date in Salesforce? ›

Use the Data Replication API: For example, use getUpdated() to retrieve updated records. Under the hood, the API uses SystemModStamp to determine the matching records, and if it doesn't exist it will automatically use LastModifiedDate or CreatedDate.

How do I find the last modified date of opportunity in Salesforce? ›

  1. Create a Process on Task object, select only when record is created as Start criteria.
  2. in the condition use WhatId Starts with Id 'Opportunity Id first three char'
  3. If Task belongs to an Opportunity, then pass the Record Id to the Flow (Use Flow as Immediate action).
4 Aug 2016

Can we change last modified date in Salesforce? ›

Created Date and Last Modified Date fields in Salesforce objects are audit fields and we can't edit or change these field directly or through code. You have to contact salesforce support team for them to grant permissions to you to edit or change these fields if needed.

What do we mean by last modified by? ›

The "Last Time Modified" date refers to the last time a document or media file was modified. This information is gathered from metadata within the document or from the website's servers.

Which entry contains the date and time the file was created or last modified? ›

File system metadata

This data is most often referred to as “MACB” times, where the “M” stands for last modification date, “A” stands for last accessed date, “C” stands for the date that the file metadata was modified, and “B” refers to the “born” or creation date of the file.

Can you change the last edited date? ›

Unfortunately it's not possible to manually change the modified date of any file in Windows.

How do I get the last modified function in SQL? ›

How do I get the last modified SP in SQL Server? You can use sys. proceedures to find the date of the most recent modification for stored procedures; SELECT [name], create_date, modify_date.

How can I add last modified date in SQL? ›

Last Update Date using SQL Trigger in SQL Server Database Table
  1. Create Table OrderItems ( ...
  2. insert into OrderItems (OrderId, ItemId, ProductId, Quantity) select 1,1,1,1. ...
  3. CREATE TRIGGER tr_OrderItems_LastUpdateDate ON OrderItems AFTER UPDATE. ...
  4. update OrderItems set Quantity = 5 where OrderId = 1 and ItemId = 2.

How do you use date modification? ›

Enter any date after datemodified: using the mm/dd/yyyy format to search for any files modified on the desired date. To find files modified between two dates, you can type the following. In this example, any files modified between January 1, 2022, and February 1, 2022, are displayed in the search results.

How do I set Lastmodifieddate in Test class? ›

executeBatch(new SfToPcRetryUpdateRecords_BatchProcess()); DateTime x5Min = System. now(). addMinutes(-5); List<Lead> ldCreated = [SELECT ID, CreatedDate, lastmodifieddate FROM Lead WHERE lastmodifieddate >= LAST_N_DAYS:1 AND lastmodifieddate < :x5Min]; System. debug('last modified date '+ldCreated);

What is Opportunity Stage history in Salesforce? ›

Stage History. Any time a user changes the Amount, Probability, Stage, or Close Date fields on an opportunity, a new entry is added to the Stage History related list. All entries include details of the change and who made it.

How do I turn on opportunity Field history? ›

Go to Set History Tracking. For accounts, contacts, leads, and opportunities select the Enable Account History, Enable Contact History, Enable Lead History, or Enable Opportunity History checkbox. Choose the fields you want to be tracked. Add the History related list to the page layout of the standard object.

Can you change date on metadata? ›

In the metadata screen, you can change the Date/Time taken next to the field Date Time Original under Camera Data (exif). You can also batch change dates by selecting multiple files and changing the date the same way for a group of images.

What is the difference between date modified and date created? ›

The rationale seems to be that "date modified" is the date when the data in the file was last updated. The "date created" is the date that a copy of the file was created on a particular disk (drive/card).

What does modified date mean? ›

The modified date of a file or folder represents the last time that file or folder was updated. If you're having trouble with the modified dates of your files or folders, check out these frequently-asked questions.


1. World record for longest catch at a sporting event and it’s by a dog! (via @Frisbee Rob)
(Omar Raja - ESPN)
2. Record Broken: NASA Just Saw The Biggest Explosion In The Universe So Far
(The Secrets of the Universe)
3. Breaking Records! (FORTNITE Season Finale Event!) K-CITY GAMING
(K-City Gaming)
4. My Best Records at The Bill Effect Event | Hill Climb Racing 2
([PR] linus)
5. LIVE: Latest News Headlines and Events l ABC News Live
(ABC News)
6. Dislyte Patch 3.1.3 Details Shimmer Record Event Save Your Gold Records
Top Articles
Latest Posts
Article information

Author: Virgilio Hermann JD

Last Updated: 01/26/2023

Views: 6025

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Virgilio Hermann JD

Birthday: 1997-12-21

Address: 6946 Schoen Cove, Sipesshire, MO 55944

Phone: +3763365785260

Job: Accounting Engineer

Hobby: Web surfing, Rafting, Dowsing, Stand-up comedy, Ghost hunting, Swimming, Amateur radio

Introduction: My name is Virgilio Hermann JD, I am a fine, gifted, beautiful, encouraging, kind, talented, zealous person who loves writing and wants to share my knowledge and understanding with you.