Visitor reverse lookup
When Send2CRM identifies a Visitor, the appropriate lookup field on the send2crm__s2cVisitor__c
record is populated with a reference to the Lead or Contact (or other standard or custom object). Although technically a Lead could be referenced from multiple Visitors, in practice this is a 1-to-1 relationship.
Sometimes you want to be able to reference the Visitor in the reverse direction, e.g. from a Lead. This makes it simple to create formula fields that look at Visitor values, for example to display the total goal value on a report or to use the website visitor id in marketing emails.
For the purposes of this example we’ll refer to Leads, but remember this can be any standard or custom object.
Create lookup field
Add a custom lookup field to the Lead. This should reference the Visitor (send2crm__s2cVisitor__c
) object. Do not make this field required.
If you add this field to a layout, configure it to be read-only so that end users cannot modify it. Don’t forget to make it editable by the Send2CRM API site guest user if required.
Create a Flow to copy the value
Type: Record-Triggered
Object: Visitor
Trigger: a record is created or updated
Entry Conditions: Formula Evaluates to True. Copy the formula below.
OR( /* Newly created Visitor with Lead populated... */ AND( ISNEW(), NOT( ISNULL( {!$Record.send2crm__Lead__c} ) ) ), /* OR updated Visitor with Lead changed. */ ISCHANGED( {!$Record.send2crm__Lead__c} ) )
When to run: Every time a record is updated
Optimize for: Actions and Related Records
Update Current Lead
Add two elements to the Flow.
Decision: Current Lead? Test if the current value of the
send2crm__Lead__c
field is NOT blank.(If 1 = Yes) Update Records: Update the new lookup field on the Lead currently related to the Visitor with the triggering record (
send2crm__s2cVisitor__c
) Id value.
Update Previous Lead
This is very similar but removes the value from the Lead previously related to the Visitor. To change the value to blank we need to add a resource:
Resource Type: Formula
Data Type: Text
Formula:
null
Add two elements:
Decision: Current Lead? Test if the prior value of the
send2crm__Lead__c
field is blank.(If 1 = Yes) Update Records: Update the new lookup field on the Lead previously related to the Visitor with a null value using the resource created above.
Save and activate the Flow.
This Flow may not be safe for bulk operations. Send2CRM does not perform bulk Visitor updates that are likely to trigger these changes, but you may wish to implement some sort of configuration/criteria that bypasses the Flow in certain circumstances. Of course these updates can also be made via Apex triggers with suitable bulk measures.