Newer Version Available
FOR REFERENCE
FOR REFERENCE is an optional clause that can be used
in a SOQL query to notify Salesforce when a
record is referenced from a custom interface, such as in a mobile application or from a custom
page.
A record is referenced every time a related record is viewed. For example, when a user views an account record, all related records (such as contacts, owner, leads, opportunities) are referenced. Consider using the FOR REFERENCE clause with the FOR VIEW clause to update recent usage data for retrieved objects.
When this clause is used with a query, two things happen:
- The LastReferencedDate field is updated for any retrieved records.
- A record is added to the RecentlyViewed object to reflect the recently referenced data for each retrieved record.
This is an example of a SOQL query that retrieves a contact and uses FOR REFERENCE to update the LastReferencedDate field of the retrieved contact.
1SELECT Name, ID FROM Contact LIMIT 1 FOR REFERENCE