Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
RecentlyViewed
Supported Calls
describeSObjects(), query(), update()
Special Usage Rules
The RecentlyViewed object doesn’t support the Event, Task, Report, KnowledgeArticle, and Article objects.
The RecentlyViewed object supports only certain objects, and supports list views only for those supported objects. Supported objects have the fields LastReferencedDate and LastViewedDate.
Fields
Usage
This object provides a heterogeneous list of different object types. The list consists of recently viewed records, records that were recently referenced (a related record was viewed), or recently viewed list views. A record is considered viewed when the user sees the record details, but not when the user sees the record in a list with other records. Use this object to programmatically construct a list of recently viewed items specific to the current user. For example, use this object on a custom user interface or for search auto-complete options. You can also retrieve a filtered list of records by object type (Type). The RecentlyViewed data is periodically truncated down to 200 records and 200 list views. RecentlyViewed data is retained for 90 days, after which it’s removed on a periodic basis.
Use this query in your code to retrieve a list of all the records and list views that were recently viewed. The results are ordered from most to least recent.
1SELECT Id, Name
2FROM RecentlyViewed
3WHERE LastViewedDate !=null
4ORDER BY LastViewedDate DESCUse this query to retrieve data that was either viewed or referenced, but only for a limited set of objects.
1SELECT Id, Name
2FROM RecentlyViewed
3WHERE Type IN ('Account', 'Contact', 'Plan__c')
4ORDER BY LastViewedDate DESCThis query retrieves a list of all recently viewed contacts with contact-specific fields, such as the contact’s account name, and the custom website field. Records are ordered from most to least recent.
1SELECT Account.Name, Title, Email, Phone, Website__c
2FROM Contact
3WHERE LastViewedDate != NULL
4ORDER BY LastViewedDate DESC