function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Querying for a user's "Recent Items" list

Is there a way to query for a particular user's "Recent Items" list?


That is, I want to be able to fetch a list of the last several records of a particular object that a particular user has viewed.



I had previously asked this as a way to update the Recent Items list, but in anycase the answer seems to be that there is no access to recent items via Apex or API.  But maybe someone else will know better.
If you just want one object you can query the last modifed by and date to get a list of recent objects by current user.  You could try "touching" an object to get it into the least recently used list.  But yes, no access to it directly.



Sadly that only gives you the most recently modified item.  Recent items is a list of recently viewed items.  Would be nice to have access to that data.  Oh well.


Thanks for the information guys.


It looks like all we can do at this point is to promote the idea to have the capability to access the recent items list:

This was delivered a while ago. The entity is RecentlyViewed ( which is queryable.
Prashant Pandey07Prashant Pandey07
FROM RecentlyViewed
WHERE LastViewedDate !=null
ORDER BY LastViewedDate DESC