Newer Version Available
RecentlyViewed
Supported Calls
Special Usage Rules
The RecentlyViewed object does not support the Task, Report, KnowledgeArticle, and Article objects.
Fields
Usage
This object provides a heterogeneous list of different object types and consists of recently viewed records or records that were recently referenced (a related record was viewed). A record is considered viewed when the user sees the details associated with it, but not when the user sees it 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, 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 per object. RecentlyViewed data is retained for 90 days, after which it is removed on a periodic basis.
Use this query in your code to retrieve a list of all the records 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