How do get the Recently Viewed items using Soql Apex Class.

As per the new Summer ’13 Release salesforce introduced the new Standard Object called RecentlyViewed, so using that we can easily get the all the recently viewed items using apex class.

here is the Sample SOQL:

SELECT Id, Name, LastViewedDate FROM RecentlyViewed  WHERE Type IN (‘Account’, ‘Contact’, ‘Case’) ORDER BY LastViewedDate DESC

Note:
The RecentlyViewed object does not support the Report, KnowledgeArticle, and Article objects.

Written by 

Salesforce MVP | Lightning Champion | 17x Salesforce Certified | Application Architect | 7x Trailhead Ranger | Techforce Services | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *

*