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

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

Written by 

3x Salesforce MVP | Platform Champion | 18x Salesforce Certified | MuleSoft Certified | 8x Trailhead Ranger | TechForce Services | Sydney | Australia

Leave a Reply

Your email address will not be published.