Idea of capturing record visitors was from one of the trailblazer community question, where a user wanted to know who is viewing the specific records in Salesforce. I came up with below solution using Flow.
Use Case: As an Admin you want to know who is visiting the records of specific objects.
Solution: Using screen flow and a custom object, we can create a record on custom object every time any user views the specific record. In this post, I’ll be capturing record visitors for Opportunities and Leads.
- Create Record Visitor Object with below fields.
Record Visitor (Custom Object)
Visited Date (DateTime) – To display when user viewed the record.
Visited User (Lookup with User Object) – To display who viewed the record.
Opportunity (Lookup with Opportunity Object)
Lead (Lookup with Lead Object)
2. Create Screen Flow.
Create two text variables as below, to get Opportunity and Lead Record Ids


Note: Make sure to select “Available for input”.
3. Use Create Records Element to Create “Record Visitor” Record
Set the field values for Record Visitor as below.

4. Create blank screen element to place on record page.

Final Flow:

Add Flow to Lightning Page:
Edit the Lead record page and drag the Flow component on to the canvas, select the flow (Record Visitor) and select the “Pass record ID into the variable” option, as this passes Lead record ID to flow.
Repeat the same steps for Opportunity record page and select the “Pass record ID into the variable” [OpportunityRecordID variable created in Flow]

OUTPUT:
Opportunity Record Visitors:

Lead Record Visitors:

Thanks for reading…