Visitor latest Session lookup
Add a relationship from the visitor record directly to the most recent session for reporting.
Visitor lookup field
Create a new field on the send2crm__s2cVisitor__c
object:
Data Type: Lookup Relationship
Related To: Session
Label: Latest Session (or as desired)
Required: un-checked
What to do if the lookup record is deleted?: Clear the value of this field
Auto add to custom report type: checked
If you wish to see the field, add it to the appropriate layout. Ensure that the Send2CRM default record owner user has write permission.
Flow
Create a new record-triggered flow to populate the new field.
Object: Session
Trigger the Flow When: A record is created or updated
Entry Conditions: IsClosed Equals False
When to Run the Flow for Updated Records: Every time
Optimize the Flow for: Actions and Related Records
Decision element
Create a decision element to determine when the session is the latest, and avoid unnecessary updates.
Update Records element
Create an element to update the visitor record related to the session, by setting the session as the latest in the new custom field.
The criteria in the decision element could also be added directly to the update records element. We kept them separate here for clarity.
Save and activate
Save and activate the flow. The new custom field on the visitor will be populated as sessions are created and updated. This will allow direct access to the session fields when reporting on visitor records.
Combine this with the Visitor reverse lookup relationship to report on Leads and Contacts with direct access to fields from the latest session.