How can I get ‘Recent Items’ object Ids in Apex (soql) is it possible

‘Recent Items’ pane shows recently viewed records for the selected tab. The list is derived from your recent items and includes records owned by you and other users.

enter image description here

Is there any way to get this in apex?

Answer

There is a new object available in Summer ’13 called RecentlyViewed that you can use in SOQL to get a user’s recently viewed records.

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

Attribution
Source : Link , Question Author : Prafulla Patil , Answer Author : Daniel Hoechst

Leave a Comment